Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Entity update and create - optimization

Note that in your code the group does not have a reference to a user, not
sure if this was a typo or not.

I would expect the merged mg to have a reference to a user that was either
remove from the database, or from the shared cache or persistence context. 
You seem to be getting just a copy of the user reference, which may mean
EclipseLink thinks this is a new object.  Is it inserted on commit?  Perhaps
include a log of what occurs on finest.  Also include what version of
EclipseLink you are using, and your mappings.


jzqa wrote:
> 
> Thanks,
> 
> I have a similar question that may help to clear things. What happens when
> i
> invoke merge() on a new entity with relationships (not marked with any
> cascading) to detached entities. Specification says:
> 
>  If X is an entity merged to X', with a reference to another entity Y,
> where
> cascade=MERGE
> or cascade=ALL is not specified, then navigation of the same association
> from X' yields a
> reference to a managed object Y' with the same persistent identity as Y.
> 
> But when i apply it to an example, Group --- m-1 --- User
> 
> User user = new User();
> user.setId(1);
> Group g = new Group();
> g.setName("name")
> 
> Group mg = em.merge(g);
> 
> When i execute above code 'mg' contains reference to a User entity 1-
> whose
> state (eager fields) is not fully loaded, 2- and when i access any lazy
> this
> managed User entity no data is fetch. Should not it behave like normal
> managed entities.
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/Entity-update-and-create---optimization-tp27919157p28083039.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top