0 Replies Latest reply on Nov 15, 2006 9:43 AM by Galo

    Some entity instances are not updated after merge

    Galo Newbie

      I have the following scenario:

      Users get into a web page, a HTTP session is created and depending on their properties they get a collecition of Entity Beans, details are displayed in the browser and they can do some updates to them. These updates are executed via a Servlet, that uses a Stateless SB to perform the operations. I.e., calling the updateFlag method below.

      When these updates happen everything seems alright, db is updated, I can find the entity with the entity manager and it retrieves the correct values etc. But if I look at the entity instance in the user session's collection its values are out of date.

      As far as I've understood, every time merge is called on an entity bean, the entity manager should take care of updating all the instances of it, so all the collections that have an instance of the entity should reflect the update. This doesn't happen even for the user that executed the update.

      Am I doing something wrong?

      This is the code that performs the action in the servlet

       NOC n = accessBean.findNOC(id);
       accessBean.updateFlag(n);
      


      SLSB
       @TransactionAttribute (TransactionAttributeType.REQUIRED)
       public NOC findNOC(Integer id) {
       return em.find(NOC.class, id);
       }
      
       @TransactionAttribute(TransactionAttributeType.REQUIRED)
       public NOC updateFlag(NOC noc) {
       noc.setFlagged(!noc.getFlagged());
       return saveNOC(noc);
       }
      
       @TransactionAttribute (TransactionAttributeType.REQUIRED)
       public NOC saveNOC(NOC noc) {
       noc.setDtTmStp(new Date());
       return em.merge(noc);
       }
      


      Thanks