Hibernate version: 2.1.7c
Code between sessionFactory.openSession() and session.close():
I'm actually to ashamed to post the code...
However, there are 2 load()s, 2 updates()s, 3 flush()s, and 3 save()s inside the one block. My guess is this, MIGHT be my problem...but please see below...
Full stack trace of any exception that occurs:
Code:
net.sf.hibernate.exception.ConstraintViolationException: could not insert: [com.XXX.gen.UserAssessmentAnswer#77239]
net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:73)
net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1332)
net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:474)
net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:438)
net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:37)
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2438)
net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2391)
net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2260)
com.XXX.pages.HandleAssessmentAction.execute(XXXAction.java:136)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
Name and version of the database you are using: mysql Ver 14.7 Distrib 4.1.7, for pc-linux (i686)
Hello all,
We have been having an issue with the above error for about a month now. The only time that the exception starts to happen is after a few days of the server running. We are not catching exceptions very well (as in we are not using a finally statement) and I believe the error above is basically stating that we have two of the same instance of object in the hibernate world, when we trying to update one.
My guess on what is causing the problem, is we are throwing exceptions between our open() and close() statements leaving open sessions with hibernate objects still in memory.
One question is:
If I open one session use it retrieve object A and it doesn't get closed correctly do to an exception, then I open a different session and work with object A again, can there be exceptions like the above one thrown?
Thanks for your time and please let me know if you require more information or explanation.
Nate