-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Missing TransactionManager when user provides a custom Neo4j SessionFactory. #17662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing TransactionManager when user provides a custom Neo4j SessionFactory. #17662
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR and the follow-up on our conversation. I've added one question and one suggestion. I'd like also that we exercise the feature you're trying to build in your custom starter (i.e. a test that provides a custom SessionFactory
and validates the necessary bits are still auto-configured.
.../main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java
Outdated
Show resolved
Hide resolved
@@ -94,6 +94,7 @@ public void customSessionFactory() { | |||
this.contextRunner.withUserConfiguration(CustomSessionFactory.class).run((context) -> { | |||
assertThat(context).doesNotHaveBean(org.neo4j.ogm.config.Configuration.class); | |||
assertThat(context).hasSingleBean(SessionFactory.class); | |||
assertThat(context).hasSingleBean(OpenSessionInViewInterceptor.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to commit this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I first had a dedicated test customSessionShouldNotDisableOSiV
, my interpretation of
(i.e. a test that provides a custom SessionFactory and validates the necessary bits are still auto-configured.
Thise commit pushes `@ConditionalOnMissingBean(SessionFactory.class)` from the main Neo4j autoconfiguration class down to the bean declaration level. In addition, the OGM configuration bean won’t be created when there’s already a `SessionFactory`. Thus, the `Neo4jWebConfiguration` will still be applied, even when user decides to run their own `SessionFactory`.
To make things explicit: I think not providing a This is the actual test for the desired behaviour and included in the PR
|
This commit separates the auto-configuration of the `SessionFactory` in an isolated class so that the rest of the auto-configuration is still applied if the user provides a custom `SessionFactory` bean. See gh-17662
Fantastic. Much appreciated. |
You mentioned that you want me to test this out with our starter. Test is already there: |
Thise commit pushes
@ConditionalOnMissingBean(SessionFactory.class)
from the main Neo4j autoconfiguration class down to the bean declaration level. In addition, the OGM configuration bean won’t be created when there’s already aSessionFactory
.Thus, the
Neo4jWebConfiguration
will still be applied, even when user decides to run their ownSessionFactory
.This change is needed to provide the mechanism proposed in #17610 in an external starter, which would provide the
SessionFactory
. As we like to provide the starter for both Boot 2.2.0 and 2.1.x, I'd like to see this change in both branches if possible.Thanks for your ongoing support in this case.