AnsweredAssumed Answered

How to replace DbIdGenerator with a db sequence

Question asked by micha1 on May 29, 2012
Latest reply on May 29, 2012 by ronald.van.kuijk
Hello activiti team and community,

we are using activiti starting from the earliest version and since three month also in a production environment - generally with great success.

Now we would like to replace the internal class 'DbIdGenerator' based on activiti tables by a solution using a db-sequence, an oracle sequence in our case. Is there any running reference code to do so? Otherwise we have to implement it ourselves.

The reason for that is a misbehavior of 'DbIdGenerator' in the context of a rollbacked transactions - IMO. The operation of fetching the next 100 IDs (default value) is unfortunately part of the user business transaction. A rollback of this transaction resets also the activiti sequence table but obviously not the active cache in 'DbIdGenerator'. Loading the next 100 IDs ends in fetching the same number block (primary key doubled!) and results periodically in constraint violations. A sequence update has to be executed outside of a user business transaction (RequiresNew). It seems that this problem is well known by activiti, unfortunatly we have not found a work around.


- Activiti 5.9
- Libs: activiti-engine / mybatis
- the engine is running inside a JBoss container (jboss-5.1)
- the activiti command shares our bean-injected EntityManager (Session)
- ProcessEngineConfiguration as follows…

                ProcessEngineConfiguration c = ProcessEngineConfiguration