0

When loading an entity twice using findOne() two different objects with the same values are returned.

I would have expected that an object identity is preserved using an Identity map.

Is there any reason why this is not the case or is there an way to influence that?

Btw, I'm using Spring JPA repositiories with eclipselink, but I have seen the same with hibernate.

David
  • 1
  • 4
    Please post code. If you load the same object twice in the same session you should get the same instance, otherwise something is wrong. – ewramner Apr 30 '18 at 07:01
  • you have to use the same EntityManager context, and depending on the setup, you might need to be in a transaction or the container might not be using the same EntityManager underneath each call. – Chris Apr 30 '18 at 17:41

0 Answers0