0 Replies Latest reply on Jun 8, 2007 9:13 AM by Francis LIMOUSY

    Id equals 0 ?

    Francis LIMOUSY Newbie

      Hello,

      I have a problem with my seam-generated app
      After saving an object using EntityHome, the id returned from the base is always '0'
      If I understand the code of the 'persist' method, the id is asked to the DBMS, after inserting a newly created entry :

       @Transactional
       public String persist()
       {
       getEntityManager().joinTransaction();
       getEntityManager().persist( getInstance() );
       getEntityManager().flush();
       assignId( PersistenceProvider.instance().getId( getInstance(), getEntityManager() ) );
       createdMessage();
       return "persisted";
       }
      


      But the "PersistenceProvider.instance().getId" returns always 0, even if the entry is properly created in the database.
      So after saving an object, I can't press the edit button, or any other else, unless an exception occur :

      org.jboss.seam.framework.EntityNotFoundException: entity not found: com.fitnetapplication.certifications.entity.Certification#0
      


      If I press the "Done" button, go back to the list and select my newly created entity, everything is fine.

      How can I make this "getId()" give me the generated id from the database ?

      I'm using seam 1.2.1, jboss 4.0.5 and mysql5 as DBMS

      Thanks for any help