You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auto-configure @EnableTransactionManagement with Neo4J #8587
When using Spring Data Neo4J, any Spring Service or Component that contains a @Transactional annotation will not result in those methods not being registered with the Neo4jTransactionManager. Consequently any group of interactions using a Spring Data Repository that should be bound by a transaction are run individually resulting in unexpected results.
changed the title [-]Spring Data Neo4J does not work with `@Transactional` when used with Spring Boot[/-][+]Spring Data Neo4J (SDN) does not work with @Transactional when used with Spring Boot 1.5.x[/+]on Mar 13, 2017
There is no processing of @Transactional because it's not enabled. If you add @EnableTransactionManagement on your sample it works (I understand the b argument in the last output must be null).
Looking at the code a bit more closely, Spring Boot never set @EnableTransactionManagement with Neo4j. So it looks like transactions with neo4j never worked out of the box. This seems a bit too obvious to me so I am wondering if the spring data neo4j team could chime in and tell me what I am missing.
@snicoll That's interesting. TransactionAutoConfiguration must be executed before the Neo4jDataAutoConfiguration which would @EnableTransactionManagement (with the appropriate transaction manager so multiple Spring Data projects that use the AbstractPlatformTransactionManager infrastructure can coordinate). Have I interpreted that incorrectly?
You are right; it does seem a little too obvious. I'm not sure how this wasn't picked up in previous releases!
@mangrish that's not what should happen. TransactionAutoConfiguration is not meant to do what you've just described. As far as I can see it never worked. Let's see what the spring data neo4j team has to say.
@snicoll: Is the recommendation to always get users to add @EnableTransactionManagement to their applications to make sure transaction management is turned on?
@mangrish the way the issue was reported sounded like a regression and I haven't seen anything anywhere that contradicts this. It isn't a regression, it never worked out of the box. We do our best to work with the team working on the underlying technology and we've done some changes in the Neo4J auto-configuration following your recommandation.
So, no, we do not recommend this. That would be inconsistent with what we do for the JPA support for instance. So we'll need to auto-configure this. I am not keen to backport that to 1.4.x though.
changed the title [-]Spring Data Neo4J (SDN) does not work with @Transactional when used with Spring Boot 1.5.x[/-][+]Auto-configure `@EnableTransactionManagement` with Neo4J[/+]on Mar 13, 2017
Activity
[-]Spring Data Neo4J does not work with `@Transactional` when used with Spring Boot[/-][+]Spring Data Neo4J (SDN) does not work with @Transactional when used with Spring Boot 1.5.x[/+]mangrish commentedon Mar 13, 2017
ping @wilkinsona: This is kind of a big deal for us. We'd appreciate any expedition you may be able to afford!
snicoll commentedon Mar 13, 2017
There is no processing of
@Transactionalbecause it's not enabled. If you add@EnableTransactionManagementon your sample it works (I understand the b argument in the last output must be null).Looking at the code a bit more closely, Spring Boot never set
@EnableTransactionManagementwith Neo4j. So it looks like transactions with neo4j never worked out of the box. This seems a bit too obvious to me so I am wondering if the spring data neo4j team could chime in and tell me what I am missing.mangrish commentedon Mar 13, 2017
@snicoll That's interesting.
TransactionAutoConfigurationmust be executed before theNeo4jDataAutoConfigurationwhich would@EnableTransactionManagement(with the appropriate transaction manager so multiple Spring Data projects that use the AbstractPlatformTransactionManager infrastructure can coordinate). Have I interpreted that incorrectly?You are right; it does seem a little too obvious. I'm not sure how this wasn't picked up in previous releases!
snicoll commentedon Mar 13, 2017
@mangrish that's not what should happen.
TransactionAutoConfigurationis not meant to do what you've just described. As far as I can see it never worked. Let's see what the spring data neo4j team has to say.mangrish commentedon Mar 13, 2017
@snicoll : That's me (the spring data neo4j team).
mangrish commentedon Mar 13, 2017
@snicoll: Is the recommendation to always get users to add
@EnableTransactionManagementto their applications to make sure transaction management is turned on?snicoll commentedon Mar 13, 2017
@mangrish the way the issue was reported sounded like a regression and I haven't seen anything anywhere that contradicts this. It isn't a regression, it never worked out of the box. We do our best to work with the team working on the underlying technology and we've done some changes in the Neo4J auto-configuration following your recommandation.
So, no, we do not recommend this. That would be inconsistent with what we do for the JPA support for instance. So we'll need to auto-configure this. I am not keen to backport that to
1.4.xthough.[-]Spring Data Neo4J (SDN) does not work with @Transactional when used with Spring Boot 1.5.x[/-][+]Auto-configure `@EnableTransactionManagement` with Neo4J[/+]mangrish commentedon Mar 13, 2017
@snicoll: Got it. Thanks for your help! I'm ok with the non backporting to
1.4.x.snicoll commentedon Apr 3, 2017
Woops, looks like I tried to fix that in #7773 but missed the bits we're discussing here.
Automatically enable transaction management for Neo4j
snicoll commentedon Apr 3, 2017
I've ran the sample with
1.5.3.BUILD-SNAPSHOTand that works OOB now.