sdbrain
sdbrain

Reputation: 3070

Transaction Isolation levels spring data neo4j

When I specify a Isolation level other than the default in @Transactional, I get the error message stating that

JtaTransactionManager does not support custom isolation levels by default - switch 'allowCustomIsolationLevels' to 'true'

I am using spring data neo4j 3.2 running neo4j in embedded mode.

I am not able to find any documentation about how to achieve this. I am trying to workaround the lost-update and inconsistent analysis problem in a project.

The neo4j website suggests to use a locking node pattern (using java api) to achieve this.

I would appreciate any suggestion on how to implement this in SDN.

Upvotes: 1

Views: 424

Answers (1)

František Hartman
František Hartman

Reputation: 15076

You can enable allowCustomIsolationLevels by

@Configuration
...
public class MyNeo4jConfig extends Neo4jConfiguration {

...

@Override
public PlatformTransactionManager neo4jTransactionManager() throws Exception {
    JtaTransactionManager transactionManager = 
        new JtaTransactionManagerFactoryBean(this.getGraphDatabaseService()).getObject();
    transactionManager.setAllowCustomIsolationLevels(true);
    return transactionManager;
}

Upvotes: 1

Related Questions