[jboss-user] [EJB 3.0] - Re: Merging an extended class from existing superclass

waynebaylor do-not-reply at jboss.com
Tue May 29 10:18:10 EDT 2007

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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049360#4049360

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049360

More information about the jboss-user mailing list