Hi,
I often encounter problems which are due to a premature close of the session - however, this is automatically done by Hibernate and leads to Transaction errors! I use the SessionUtil of the CaveatEmptor (SE).
In my case, I try to insert an object:
Code:
SessionUtil.beginTransaction();
Session session = SessionUtil.getSession();
p = (Person) session.load(Person.class, p.getId());
session.delete(p);
SessionUtil.commitTransaction();
SessionUtil.closeSession();
Sometimes everything works fine, and then suddenly I get the mentioned transaction errors (see log below) or I even cannot add objects because they cannot be identified by Hibernate anymore.
The sequence for the object to be deleted (in this case) is derived from a Postgresql-Sequence.
I need your help ...
Hibernate version: 3.05
Name and version of the database you are using: Postgres 7.4
Full stack trace of any exception that occurs:[STDOUT] Hibernate: select nextval ('sq_personen_id')
09:16:11,831 INFO [STDOUT] null:
Session is closed
Debug level Hibernate log excerpt:Code:
2005-06-22 09:16:11,805 INFO [STDOUT] Hibernate: select nextval ('sq_personen_id')
2005-06-22 09:16:11,805 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-06-22 09:16:11,806 DEBUG [org.hibernate.id.SequenceGenerator] Sequence identifier generated: 17
2005-06-22 09:16:11,806 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-06-22 09:16:11,806 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2005-06-22 09:16:11,806 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] generated identifier: 17, using strategy: org.hibernate.id.SequenceGenerator
2005-06-22 09:16:11,806 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] saving [xxxxxxx..Person#17]
2005-06-22 09:16:11,807 DEBUG [xxxxxxx.SessionUtil] Committing database transaction of this thread.
2005-06-22 09:16:11,807 DEBUG [org.hibernate.transaction.JDBCTransaction] commit
2005-06-22 09:16:11,807 DEBUG [org.hibernate.impl.SessionImpl] automatically flushing session
2005-06-22 09:16:11,807 DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
2005-06-22 09:16:11,807 DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
2005-06-22 09:16:11,830 DEBUG [xxxxxxx.SessionUtil] Trying to rollback database transaction of this thread.
2005-06-22 09:16:11,830 DEBUG [org.hibernate.transaction.JDBCTransaction] rollback
2005-06-22 09:16:11,830 DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
2005-06-22 09:16:11,830 DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
2005-06-22 09:16:11,830 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
2005-06-22 09:16:11,830 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
2005-06-22 09:16:11,830 DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
2005-06-22 09:16:11,831 INFO [STDOUT] null:
Session is closed
2005-06-22 09:16:11,831 DEBUG [xxxxxxx.SessionUtil] Closing Session of this thread.
2005-06-22 09:16:11,831 DEBUG [org.hibernate.impl.SessionImpl] closing session
2005-06-22 09:16:11,831 DEBUG [org.hibernate.jdbc.ConnectionManager] closing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2005-06-22 09:16:11,831 DEBUG [org.hibernate.connection.DriverManagerConnectionProvider] returning connectionto pool, pool size: 1