Joined: Mon Oct 23, 2006 9:03 am Posts: 5 Location: La Spezia, Italy
|
We have a web application with a swing remote client that comunicate using http invoker protocol (Spring + Hibernate).
We can't use version or timestamp columns to implement offline optimistic locking...so we need to keep open hibernate session between different client calls.
We save the session in the httpsession using a servlet filter.
We have this problem: when we try to save the object changed on the client we obtain this exception:
********************************************************
caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:556)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:259)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:217)
at org.hibernate.event.def.DefaultUpdateEventListener.performSaveOrUpdate(DefaultUpdateEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireUpdate(SessionImpl.java:564)
at org.hibernate.impl.SessionImpl.update(SessionImpl.java:552)
at org.hibernate.impl.SessionImpl.update(SessionImpl.java:544)
at org.springframework.orm.hibernate3.HibernateTemplate$14.doInHibernate(HibernateTemplate.java:647)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:362)
********************************************************
because of serialization change object id. If we use detached objects we don't have this problem.
How we can change our objects on the client and save them with hibernate long session?
Any help is appreciated :)
_________________ A T
|
|