Hi,
My Hibernate application was working perfectly when I was connecting to SQL Server 2000. When I upgraded to SP3, the application is having problems inserting records. Select query works fine. Inserts and updates fail with the following error:
ERROR impl.SessionImpl - Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
I tried both Microsoft and JTDS JDBC drivers.
Hibernate version:
2.0
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="org.jbpm.persistence.hibernate.SequenceBlock" table="JBPM_SEQUENCEBLOCK">
<id name="id" type="long" unsaved-value="null">
<generator class="assigned" />
</id>
<property name="nextId" type="long" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
session = sessionFactory.openSession();
log.debug("beginning a jbpm id-sequence transaction" );
Transaction transaction = session.beginTransaction();
SequenceBlock sequenceBlock = null;
try {
log.debug( "check the sequence block in the db for nodeId: " + nodeId );
sequenceBlock = (SequenceBlock) session.load( SequenceBlock.class, new Long( nodeId ) );
} catch (ObjectNotFoundException e) {
// e.printStackTrace();
log.debug( "no sequence block found for " + nodeId + ", creating a new one" );
sequenceBlock = new SequenceBlock( new Long( nodeId ) );
}
log.debug( "fetched sequence block from db: " + sequenceBlock );
// a block is reserved for all nodes in the cluster
long firstIdOfCompleteBlock = sequenceBlock.getNextBlock(blockSize * maxNodes);
log.debug( "first id of overall block is: " + firstIdOfCompleteBlock );
// this node only consumes a part of the block
nextId = firstIdOfCompleteBlock + (blockSize * nodeId);
lastId = nextId + blockSize - 1;
session.save( sequenceBlock );
session.flush();
log.debug("committing a jbpm id-sequence transaction" );
transaction.commit();
log.debug("updated sequence block " + sequenceBlock + " was commited" );
log.debug("got a new block of ids for this node: " + nextId + ", " + lastId );
} catch (HibernateException e) {
e.printStackTrace();
throw new ChainedRuntimeException( "couldn't get a new block of ids", e );
} finally {
try {
if ( session != null ) session.close();
} catch (HibernateException e) {
e.printStackTrace();
throw new ChainedRuntimeException( "couldn't get a new block of ids", e );
}
Full stack trace of any exception that occurs:
[deploypar] 13797 [main] INFO impl.DefinitionServiceImpl - deploying process archive...
[deploypar] 14719 [main] ERROR impl.SessionImpl - Could not synchronize database state with session
[deploypar] net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)
[deploypar] at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:25)
[deploypar] at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
[deploypar] at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
[deploypar] at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
[deploypar] at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
[deploypar] at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
[deploypar] at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
[deploypar] at org.jbpm.persistence.hibernate.SequenceBlockIdGenerator.getNextId(SequenceBlockIdGenerator.java:105)
[deploypar] at org.jbpm.persistence.hibernate.SequenceBlockIdGenerator.getNextId(SequenceBlockIdGenerator.java:64)
[deploypar] at org.jbpm.persistence.hibernate.ConfigurableIdGenerator.generate(ConfigurableIdGenerator.java:48)
[deploypar] at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:765)
[deploypar] at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
[deploypar] at org.jbpm.persistence.hibernate.HibernateSession.save(HibernateSession.java:138)
[deploypar] at org.jbpm.impl.DefinitionServiceImpl.deployProcessArchive(DefinitionServiceImpl.java:39)
[deploypar] at org.jbpm.ant.DeployParTask.execute(DeployParTask.java:44)
[deploypar] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[deploypar] at org.apache.tools.ant.Task.perform(Task.java:364)
[deploypar] at org.apache.tools.ant.Target.execute(Target.java:341)
[deploypar] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[deploypar] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
[deploypar] at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
[deploypar] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[deploypar] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[deploypar] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[deploypar] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Name and version of the database you are using:
SQL Server 2000 SP3
The generated SQL (show_sql=true):
Hibernate: update JBPM_SEQUENCEBLOCK set nextId=? where id=?
Debug level Hibernate log excerpt:
|