Reputation: 648
Hi I am getting following error while saving NodeEntity object by using Neo4jTemplate
Cannot perform data updates in a transaction that has performed schema updates
Spring-data :-
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>3.1.0.BUILD-SNAPSHOT</version>
Neo4j Version : 2.X
Service :-
@Override
@Transactional
public void addRepository(Repository repository) {
template.save(repository);
}
Caused by: org.neo4j.kernel.api.exceptions.InvalidTransactionTypeKernelException: Cannot perform data updates in a transaction that has performed schema updates. at org.neo4j.kernel.impl.api.KernelTransactionImplementation$TransactionType$2.upgradeToDataTransaction(KernelTransactionImplementation.java:452) at org.neo4j.kernel.impl.api.KernelTransactionImplementation.upgradeToDataTransaction(KernelTransactionImplementation.java:212) at org.neo4j.kernel.impl.api.KernelStatement.dataWriteOperations(KernelStatement.java:84) at org.neo4j.kernel.InternalAbstractGraphDatabase.createNode(InternalAbstractGraphDatabase.java:1033) ... 49 more
Upvotes: 2
Views: 1159
Reputation: 22171
SDN 3.0.0 needs now to have base-package
configured in your Spring configuration.
Indeed, this is now needed since Neo4j 2.0.X doesn't allow insertion of index (schema change involved by your first save
operation) in the same transaction as a data update (save
of your entity in your case).
So if you use XML configuration for Spring, it would looks like:
<neo4j:config graphDatabaseService="graphDatabaseService" base-package="com.myApp.myDomainPackage" />
where com.myApp.myDomainPackage
contains all the node entities.
instead of simple:
<neo4j:config graphDatabaseService="graphDatabaseService"/>
Upvotes: 1
Reputation: 39905
Data updates and schema changes need to happen in separate transactions. If they would be allowed in the same transaction various sorts of weirdness would be possible.
Upvotes: 0