Better exception message for version type mismatch

Description

Documentation says correctly that the default type of a version is integer. When you don't specify the type and use a long member field, hibernate doesn't use reflection to determine the type of the version member field and generates an exception that doesn't really relate to the problem:

java.lang.RuntimeException: problem closing service 'org.jbpm.persistence.db.DbPersistenceService@1292d12'
at org.jbpm.svc.Services.close(Services.java:179)
at org.jbpm.JbpmContext.close(JbpmContext.java:116)
at org.jbpm.db.AbstractDbTestCase.closeJbpmContext(AbstractDbTestCase.java:108)
at org.jbpm.db.AbstractDbTestCase.tearDown(AbstractDbTestCase.java:39)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.jbpm.persistence.PersistenceException: couldn't commit hibernate session
at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:118)
at org.jbpm.svc.Services.close(Services.java:172)
... 19 more
Caused by: org.hibernate.AssertionFailure: null id in org.jbpm.graph.exe.ProcessInstance entry (don't flush the Session after an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:140)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:97)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:877)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:344)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:116)
... 20 more

The exception is thrown from DefaultFlushEventListener.checkId:

/**

  • make sure user didn't mangle the id
    */
    public void checkId(Object object, EntityPersister persister, Serializable id, EntityMode entityMode)
    throws HibernateException {

if ( persister.hasIdentifierPropertyOrEmbeddedCompositeIdentifier() ) {

Serializable oid = persister.getIdentifier( object, entityMode );
if (id==null) {
throw new AssertionFailure("null id in " + persister.getEntityName() + " entry (don't flush the Session after an exception occurs)");
}
if ( !persister.getIdentifierType().isEqual(id, oid, entityMode) ) {
throw new HibernateException(
"identifier of an instance of " +
persister.getEntityName() +
" was altered from " + id +
" to " + oid
);
}
}

}

regards, tom.

Environment

None

Activity

Show:
Brian Viveiros
September 7, 2006, 3:07 PM

I'm seeing this when a JBPM timer triggers an Action. The Action creates a new hibernate session and does some database work then comits.

The following line in org.jbpm.scheduler.impl.SchedulerThread.executeTimers() results in the exception:

// save the process instance
jbpmContext.save(timer.getProcessInstance());

Is there a workaround to suppress this message? I can set logging to something higer than INFO but then I might miss out on other messages.

Thanks.

Assignee

Unassigned

Reporter

TomT

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure