-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ConstraintViolationException
PostPosted: Thu Dec 16, 2004 8:18 pm 
Newbie

Joined: Thu Dec 16, 2004 7:20 pm
Posts: 2
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.