cancel
Showing results for 
Search instead for 
Did you mean: 

How to replace DbIdGenerator with a db sequence

micha1
Champ on-the-rise
Champ on-the-rise
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.

Thx,
Micha

Environment:
- 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
                .createStandaloneProcessEngineConfiguration()
                .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
                .setTransactionsExternallyManaged(true)
                .setHistory(ProcessEngineConfiguration.HISTORY_NONE)
                .setJpaCloseEntityManager(false)
                .setJobExecutorActivate(true);
        c.setDataSourceJndiName("java:/abis");
1 REPLY 1

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
if you pass in a transactionmanager in the config, a new transaction IS used for obtaining the next block of id's afaik.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.