Two entities, Picture and Person, ManyToOne 

Class Picture { 

.... 
@ManyToOne 
public Person getOwner() {... } 

} 


Picture picture = <a detached entity> 
// the picture has a owner that is an instance of Person(not CGLIB enhanced). 
//change picture name, then merge 
Picture p = em.merge(picture); 

The owner(Person) of p is changed to a CGLIB enhanced instance, and its all 
member variables become null. It has an Initializer that says initialized=true. 

Why is that? I expected the object returned from em.merge() would keep all the 
data. 

One thing I do not understand: 

em.create(entity) will change entity directly. For merge, why it return a 
different instance? which instance should I work on after merge? 

Thanks for help.

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

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


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to