Hi,
First, thanks for your replies. here is more informations :
Answer to your question :
---------------------
mgrEntreprise.saveAffrete(affrete) is a service class that just call the dao class and the dao do getHibernateTemplate().saveOrUpdate(objet).
In my database i have :
---------------------------
A empty table : "affrete" with only an id property (primary and foreign key to entreprise table).
entreprise table with already information for example :
|id | raisonSociale|
|1 | my company|
In fact i want to create a record in affrete table with the same id already in the entreprise table.
Code is :
Code:
affrete=new Affrete();
affrete.setId(new Long(request.getParameter("idAffrete"))); //idaffrete=1
mgrEntreprise.saveAffrete(affrete);
Stack trace :
---------------
Code:
ERROR - FrameworkServlet.service(342) | Could not complete request
org.springframework.orm.hibernate.HibernateSystemException: a different object with the same identifier value was already associated with the session: 1, of class: org.astre.sig.modele.Affrete; nested exception is net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 1, of class: org.astre.sig.modele.Affrete
net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 1, of class: org.astre.sig.modele.Affrete
at net.sf.hibernate.impl.SessionImpl.checkUniqueness(SessionImpl.java:1673)
at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1442)
at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1469)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1392)
at org.springframework.orm.hibernate.HibernateTemplate$13.doInHibernate(HibernateTemplate.java:320)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:317)
at org.astre.sig.dao.hibernateImpl.AffreteDAOHibernate.save(AffreteDAOHibernate.java:23)
at org.astre.sig.service.EntrepriseManagerImpl.saveAffrete(EntrepriseManagerImpl.java:159)
Thanks,
Fabien.