This content has been marked as final.
Show 1 reply
-
1. Re: Persistence Context issues
lvdberg Jun 17, 2011 3:19 AM (in response to monkeyvu)Hi,
I never use contains. The API states:
Check if the instance belongs to the current persistence contextand I can imagine that after saving and loosing the actual EntityManager, a call to contains with a new entityManager will return false. I assume you want to know if the entity is in the database (that's something different), so the second method does that for you (it retrieves it if it exists and then puts it in the context (!) another method is refresh, which does exactly what it staes: It takes the data from the DB and
refreshes
the entity..If you keep everything in the same conversation it will probably return true with contains, because it won't
dis-connect
the entityManager.Leo