0 Replies Latest reply on Nov 23, 2005 5:36 AM by fabboco

    Different object with the same identifier value was already

    fabboco

      Hi,

      I am still posting about this issue since I am not able to define if it's a bug or a mistake.

      I am planning to use EJB3 in a project in the near future, but probably I have to go back to EJB2.x.

      
      MasterManager managerMaster = (MasterManager) myUtils.getBean("masterdetail.manager.interfaces.MasterManagerRemote");
      
      Master master = managerMaster.find((Long) myForm.get("id"));
      
      UserTransaction ut = myUtils.getTransaction();
      ut.begin();
      
      List<masterdetail.entity.Detail> getDetails_Details = master.getDetails();
      
      masterdetail.manager.interfaces.DetailManagerRemote managerDetail = (masterdetail.manager.interfaces.DetailManagerRemote) myUtils.getBean("masterdetail.manager.interfaces.DetailManagerRemote");
      
      for (masterdetail.entity.Detail Detail : getDetails_Details)
      {
       Detail.setMaster(null);
       managerDetail.merge(Detail);
      }
      
      managerMaster.remove(master);
      
      if (ut.getStatus() == Status.STATUS_ACTIVE)
       ut.commit();
      
      


      @Stateless
      public class MasterManagerBean implements MasterManagerRemote, MasterManagerLocal
      {
       @PersistenceContext
       private EntityManager manager;
      ......
       public void remove(Master MasterVariable)
       {
       manager.remove(MasterVariable);
       }
      }
      



      When I try to delete the Master bean (id = 21) I get the following error:



      javax.ejb.EJBTransactionRolledbackException: null; CausedByException is: a different object with the same identifier value was already associated with the session: [masterdetail.entity.Master#21] at
      ....
      ....


      Please help !

      Ciao

      Fabrizio