0 Replies Latest reply on Aug 24, 2009 12:41 PM by Thorsten Schwarz

    EntityBean loading: immediate update after read an entity

    Thorsten Schwarz Newbie

      Hi all,

      I have a strange behavior of my EJB 3.
      As soon as I read an entity using the EntityManager I can see an select statement send to the database, but followed by an immediate update statement that is send to the database.

      I have a couple of finder-methods in my session bean. That methods are using the EntityManger to find my entity beans. Even a simple invocation of a find by primary key method is leads to an immediate update.

      After every update the entity's version is changed, making it impossible to save my real changes, that are coming from the presentation layer.

      Any idea what might be the reason for those strange updates? How can I change this?

      Code sniplet:

      @Stateless
      public class OrderServiceBean {
      
       @PersistenceContext
       private EntityManager em;
      
       public Order findOrderById(Long id) {
       return em.find(Vorgang.class, id);
       }
      
      }
      


      Thanks for your help in advance
      Thorsten