[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] Removed entity can still be found by other entity manager instances
|
Hello everyone,
imagine the following situation:
User newObj = new User ();
newObj.setUserMode('A');
em1.persist(newObj);
id = newObj.getUserId();
assertNull(em2.find(User.class, id)); //no exception, entity can
not be found yet.
//...committing/beginning transaction of em1 here...
assertNotNull(em2.find(User.class, id)); //no exception, entity is found
em1.remove(newObj);
//...committing/beginning transaction of em1 here...
//after commit of em1:
assertNull(em1.find(User.class, id)); //no exception, entity is removed!
assertNull(em2.find(User.class, id)); //exception! em2 can still
find and access the removed entity!
As you can see, an entity manager can still access a removed entity
(by an other entity manager) if it has been fetched before its removal.
Even more odd, this entity can be changed without any exceptions after
commiting and when looking into the finest logs, entity manager em2
seems to execute an update SQL but doesn't check
that no records have updated.
I would expect at least an exception on this, or even better that the
last assertion won't fail already.
How can I archive that? And how to archive that if an external
application deletes/modifies a record?
I tried disabling all caching by setting
eclipselink.cache.type.default to "NONE", but this didn't help.
Excerpt from my persistence.xml:
<property name="eclipselink.cache.shared.default" value="false"/>
Best regards,
Patric