Hibernate validator and roll back errors
talios Oct 23, 2008 12:14 AMHey all,
Has anyone had any issues with envers and Hibernate Validator? Esp. when the validator throws an InvalidStateException for validation errors?
I'm noticing envers doing some weird shiz under this condition which is causing some real weird headaches for our app.
The first exception I see (hibernate validator) is:
org.hibernate.validator.InvalidStateException: validation failed for: smx3.schema3.TelecomNumber at org.hibernate.validator.event.ValidateEventListener.validate(ValidateEventListener.java:148) at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:172) at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:160)
which is immediately followed up with the following envers based exception (I'm blaming envers based on its appearance in the trace):
23.10.2008 16:35:24.018 *WARN* [btpool0-13] org.hibernate.util.JDBCExceptionReporter SQL Error: 0, SQLState: 23505 23.10.2008 16:35:24.018 *ERROR* [btpool0-13] org.hibernate.util.JDBCExceptionReporter ERROR: duplicate key violates unique constraint "pk_party" 23.10.2008 16:35:24.019 *ERROR* [btpool0-13] org.hibernate.event.def.AbstractFlushingEventListener Could not synchronize database state with session org.hibernate.exception.ConstraintViolationException: could not insert: [smx3.schema3.Party] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2272) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2665) at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:60) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000) at org.jboss.envers.synchronization.VersionsSync.beforeCompletion(VersionsSync.java:138) at com.atomikos.icatch.jta.Sync2Sync.beforeCompletion(Sync2Sync.java:73) at com.atomikos.icatch.imp.TransactionStateHandler.commit(TransactionStateHandler.java:253) at com.atomikos.icatch.imp.CompositeTransactionImp.doCommit(CompositeTransactionImp.java:509) at com.atomikos.icatch.imp.CompositeTerminatorImp.commit(CompositeTerminatorImp.java:138)
Beyond thinking envers shouldn't even be triggered under this circumstance (Hibernate shouldn't be getting passed org.hibernate.action.EntityInsertAction#preInsert to trigger the postInsert listeners - so why is envers waking up?) I'm intrigued by this looking like Hibernate wanting to insert my smx3.schema3.Party entity rather Party_versions.
I wonder if this was a known issue thats resolve in the 1.x series (we're still running a 0.9 build due to other issues mentioned elsewhere in the forum).
Cheers,
Mark