20:41:15
Today do a saveorupdate operation error:
Org.springframework.orm.hibernate3.hibernatesystemexception:a different object with the same identifier value is Already associated with the session: [com.xshcar.carcloud.entity.uboxtbl#1291]; Nested exception is org.hibernate.nonuniqueobjectexception:a different object with the same identifier value was already Associated with the session: [com.xshcar.carcloud.entity.uboxtbl#1291]
A classic hibernate error: A different object with the same identifier value is already associated with the session XXXX
hibernate3.0 using merge () to merge the same object in the two session
Solve:
Call Hibernate's gethibernatetemplate (). Merge (Object) method on the Daoimpl layer;
Public Boolean executeupdate (T-t) {boolean b=true; Try { T= (t)this. Gethibernatetemplate (). Getsessionfactory (). Getcurrentsession (). Merge (t); Gethibernatetemplate (). Update (t); Catch (DataAccessException e) { e.printstacktrace (); b=false; } return b; }
Resolve a different object with the same identifier value is already associated with the session error