This content has been marked as final. 
    
Show                 2 replies
    
- 
        1. Re: Merging an extended class from existing superclasswolfc May 25, 2007 6:23 AM (in response to reuben.helms)Reconsider the livecycle of your object. For example: Dog dog = new Dog("Tom"); <do magic here> assert dog instanceof SpottedDog : "magic failed";
 I can't think of any magic that won't fail.
 So the only solution is to make the SpottedDog an one on one association with Dog.
 The code will then be some like:@Entity public class SpottedDog { @Id Long id; @OneToOne @PrimaryKeyColumnJoin Dog dog; }
 You may need to fully specify the one to one relationship as it may be an one way association.
- 
        2. Re: Merging an extended class from existing superclasswaynebaylor May 29, 2007 10:18 AM (in response to reuben.helms)I think there is a conceptual issue here. What you are trying is analogous to casting a Dog object to a SpottedDog object, which is bad--a Dog is not always a SpottedDog. 
 I suggest you remove the existing Dog object, then save the SpottedDog object.
 For example:Dog d = em.find(Dog.class, ID); SpottedDog sd = new SpottedDog(d); sd.set*(...); ... em.remove(d); em.persist(sd); //you could also use em.merge(sd) here 
 
     
    