• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.hibernate.NonUniqueObjectException

 
Mak Buster
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We have a web-application which is webSSO enabled. Things were fine unless I added below piece of code as below



It erupts in below

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.db.mmrepo.common.model.magellan.GripUser#40000194] org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:411)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:354)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.db.mmrepo.app.magellanweb.util.filter.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:23)


root cause

org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.db.mmrepo.common.model.magellan.GripUser#40000194]
org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:556)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:259)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:217)
org.hibernate.event.def.DefaultUpdateEventListener.performSaveOrUpdate(DefaultUpdateEventListener.java:33)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
org.hibernate.impl.SessionImpl.fireUpdate(SessionImpl.java:564)
org.hibernate.impl.SessionImpl.update(SessionImpl.java:552)
org.hibernate.impl.SessionImpl.update(SessionImpl.java:544)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
$Proxy0.update(Unknown Source)
com.db.mmrepo.app.magellanweb.security.UserAuthenticator.authenticateUser(UserAuthenticator.java:108)
com.db.mmrepo.app.magellanweb.security.RequestSecurityInterceptor.preHandle(RequestSecurityInterceptor.java:30)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:809)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:754)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:399)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:354)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.db.mmrepo.app.magellanweb.util.filter.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:23)


I printed the completed current session, and I found it already has a EntityKey[com.db.mmrepo.common.model.magellan.GripUser#40000194]

I didnt understand as I am performing this update on the current session only. Is there something that I can do to get past this?

Kindly Advice.
 
Manuel Petermann
Ranch Hand
Posts: 177
Hibernate Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont exactly know what your user.getGripUser().getUserSid() returns but it seams that it is an id which is already associated with the session.
To help you fix the problem it is mandatory to know what the scope of your session is and what your implementation of getCurrentSession() is doing.

1. Where is user coming from?
2. Scope of session?
3. Is getCurrentSession() just a delegate to SessionFactory.getCurrentSession()?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic