1 Reply Latest reply on Jan 16, 2009 9:55 AM by Stephen Friedrich

    EntityManager find() returns old Entities

    Dmitry Shultz Newbie


      I have Seam 2.1.1 on Glassfish and it mostly works well or probably it works 100% but I'm expecting something that doesn't supposed to work the way I'm expecting.

      I have following config for the EntityManager:

      <persistence:entity-manager-factory name="someDS"/>
          <persistence:managed-persistence-context name="entityManager"

      Where 'someDS' is configured to use Hibernate MySQLDialect.

      EntityManager is injected by Seam into the POJO with CONVERSATION Scope and the same Conversation is maintained for several pages.

      I have a problem with multiple sessions (several browsers) when some entity is updated from one session (and i see the update commited in the database), but when another instance of this entity is reloaded by another session (entityManager)  it still has the old data.
      I tried to load it using find() and JPQL but the result is the same, - looks like the entityManager loading the entity from the cache.

      Is it expected?
      My thought was that all entityManager instances running in the same application will be updated to exclude the 'dirty' entity from the cache.

      How can I force the entityManager to load it from Database instead of cache?