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.

----- James Sutherland
 EclipseLink ,
Wiki: EclipseLink , TopLink 
Forums: TopLink , EclipseLink 
Book: Java Persistence 
View this message in context:
Sent from the EclipseLink - Users mailing list archive at

Back to the top