Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Duplicate Entities in GlassFish Persistence Context


I am getting duplicate managed Entities in EntityManager in a single

This happens only in GlassFish, not with a JUnit test that uses
transaction-type="RESOURCE_LOCAL" in persistence.xml.

After retrieveal from an object query, the same entities are looked up
again using EntityManager.find().

find() gets the duplicates. I spotted them because they "lost" some
transient fields that were set prior to find(), and they have
different Object hashcodes.

One could argue that there is no contract that stipulates that
EntityManager must return identical entities for the same entity type
and ID within the same transaction.

However, there is also no reason for such a waste of memory because if
I can compare them, then I have the references to them and they cannot
be garbage collected anyway.

Is this a bug? Should I report this?

The scenario is very difficult to deal with - it limits my programming
options quite a bit. It is scary and frustrating.



Back to the top