[jboss-user] [JBoss Seam] - Id equals 0 ?

limousyf do-not-reply at jboss.com
Fri Jun 8 09:13:01 EDT 2007


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

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052568#4052568

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052568



More information about the jboss-user mailing list