I am having issues attempting to save new records. I am calling saveOrUpdate(), which is generating two insert statements (only one call to get the sequence). This is only happening in unit testing of dao's, this does not happen if we test the service level (which calls the dao's). The service level objects extend a transaction manager, whereas the dao's do not.
So, I am guessing that there is a problem with the transaction management, but I am unable to figure out where.
Has anyone seen anything like this before?
Hibernate version: 3.1.2
Mapping documents:
Code between sessionFactory.openSession() and session.close():
getCurrentSession().saveOrUpdate(o);
Full stack trace of any exception that occurs:
[epp] ERROR [main] AbstractFlushingEventListener.performExecutions(299) | Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:356)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:496)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:469)
at org.compass.spring.transaction.SpringSyncTransaction.doCommit(SpringSyncTransaction.java:125)
at org.compass.core.transaction.AbstractTransaction.commit(AbstractTransaction.java:38)
Name and version of the database you are using:
Oracle XE
The generated SQL (show_sql=true):
Hibernate: select voc_primary_key_sequence.nextval from dual
done..... 132
Hibernate: insert into voc_site (version, name, description, notes, timeZone, id) values (?, ?, ?, ?, ?, ?)
Hibernate: insert into voc_site (version, name, description, notes, timeZone, id) values (?, ?, ?, ?, ?, ?)
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
I am guessing that the transaction management is not functioning as expected.
Read this:
http://hibernate.org/42.html