GH-2888 - Fix eager PlatformTransactionManager dependency.

Closes #2888
This commit is contained in:
Gerrit Meier
2024-04-04 16:01:36 +02:00
parent 58c184a7a8
commit 147a3fdff8
2 changed files with 10 additions and 4 deletions

View File

@@ -90,6 +90,7 @@ import org.springframework.data.neo4j.core.mapping.RelationshipDescription;
import org.springframework.data.neo4j.core.mapping.SpringDataCypherDsl;
import org.springframework.data.neo4j.core.mapping.callback.EventSupport;
import org.springframework.data.neo4j.core.schema.TargetNode;
import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager;
import org.springframework.data.neo4j.repository.NoResultException;
import org.springframework.data.neo4j.repository.query.QueryFragments;
import org.springframework.data.neo4j.repository.query.QueryFragmentsAndParameters;
@@ -1093,8 +1094,10 @@ public final class Neo4jTemplate implements
this.renderer = Renderer.getRenderer(cypherDslConfiguration);
this.elementIdOrIdFunction = SpringDataCypherDsl.elementIdOrIdFunction.apply(cypherDslConfiguration.getDialect());
this.cypherGenerator.setElementIdOrIdFunction(elementIdOrIdFunction);
this.transactionTemplate = new TransactionTemplate(beanFactory.getBean(PlatformTransactionManager.class));
this.transactionTemplateReadOnly = new TransactionTemplate(beanFactory.getBean(PlatformTransactionManager.class), readOnlyTransactionDefinition);
PlatformTransactionManager transactionManager = beanFactory.getBeanProvider(PlatformTransactionManager.class).getIfUnique(() -> beanFactory.getBean(Neo4jTransactionManager.class));
this.transactionTemplate = new TransactionTemplate(transactionManager);
this.transactionTemplateReadOnly = new TransactionTemplate(transactionManager, readOnlyTransactionDefinition);
}
// only used for the CDI configuration

View File

@@ -67,6 +67,7 @@ import org.springframework.data.neo4j.core.mapping.RelationshipDescription;
import org.springframework.data.neo4j.core.mapping.SpringDataCypherDsl;
import org.springframework.data.neo4j.core.mapping.callback.ReactiveEventSupport;
import org.springframework.data.neo4j.core.schema.TargetNode;
import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager;
import org.springframework.data.neo4j.repository.query.QueryFragments;
import org.springframework.data.neo4j.repository.query.QueryFragmentsAndParameters;
import org.springframework.data.projection.ProjectionFactory;
@@ -1181,8 +1182,10 @@ public final class ReactiveNeo4jTemplate implements
this.renderer = Renderer.getRenderer(cypherDslConfiguration);
this.elementIdOrIdFunction = SpringDataCypherDsl.elementIdOrIdFunction.apply(cypherDslConfiguration.getDialect());
this.cypherGenerator.setElementIdOrIdFunction(elementIdOrIdFunction);
this.transactionalOperatorReadOnly = TransactionalOperator.create(beanFactory.getBean(ReactiveTransactionManager.class), readOnlyTransactionDefinition);
this.transactionalOperator = TransactionalOperator.create(beanFactory.getBean(ReactiveTransactionManager.class));
ReactiveTransactionManager reactiveTransactionManager = beanFactory.getBeanProvider(ReactiveTransactionManager.class)
.getIfUnique(() -> beanFactory.getBean(ReactiveNeo4jTransactionManager.class));
this.transactionalOperatorReadOnly = TransactionalOperator.create(reactiveTransactionManager, readOnlyTransactionDefinition);
this.transactionalOperator = TransactionalOperator.create(reactiveTransactionManager);
}
@Override