About Question enthuware.oce-jpad.v6.2.484 :

Moderator: admin

Post Reply
romsky
Posts: 39
Joined: Thu Jan 29, 2015 4:49 pm
Contact:

About Question enthuware.oce-jpad.v6.2.484 :

Post by romsky »

I am confused with third option.

[Option] The customer with primary key matching custID has become detached.
[Explanation] In this case, the customer will become managed again.

That is wrong. If the entity is detached, only the calling persist() can make it managed again.
The calling find() will return null.

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.484 :

Post by admin »

Why do you think so?
find cannot return null if a row exists in the database.
If you like our products and services, please help us by posting your review here.

romsky
Posts: 39
Joined: Thu Jan 29, 2015 4:49 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.484 :

Post by romsky »

admin wrote:Why do you think so?
find cannot return null if a row exists in the database.
Can it be that the entity is removed from database(during commit of pre transaction) and it then stays as detached in EM? Calling find() on such EM will return null or not ?

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-jpad.v6.2.484 :

Post by admin »

Yes, but deletion is not the only cause for detachment. You could just detach an entity from the entity manager by calling em.detach(entityRef) also.
So just because an entity is detached doesn't necessarily mean that find will return null.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests