Hibernate version: 2.1.7
Full stack trace of any exception that occurs:
Code:
Caused by: net.sf.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: 31, of class: FooBar
at net.sf.hibernate.impl.SessionImpl.checkUniqueness(SessionImpl.java:1686)
at net.sf.hibernate.impl.SessionImpl.doUpdateMutable(SessionImpl.java:1452)
at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1479)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1402)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:482)
at net.sf.hibernate.impl.SessionImpl.doUpdate(SessionImpl.java:1484)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1402)
at org.springframework.orm.hibernate.HibernateTemplate$14.doInHibernate(HibernateTemplate.java:390)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:228)
... 62 more
Hi,
I've read about this exception, so I think I know what it means.
However, I am completely clueless, how this exception ever can occur when calling a saveOrUpdate(obj) with an empty session. The object to be saved was loaded before via session.load(class, id) in a former HTTP request and not altered. I'm using the OpenSessionInView filter of Spring. To be sure I invoked session.clear() before saveOrUpdate().
So obj is a detached instance. In fact every object in the graph spanned by obj is detached.
Does it mean that this is Hibernate's fault?
Any idea where to investigate?
Oliver