Skip to content

Upgrade to Spring Data Neo4j 6 #22299

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

Closed

Conversation

meistermeier
Copy link
Contributor

This PR adapts Spring Boot 2.4 to Spring Data Neo4j 6.

For some background:
Neo4j has developed two projects in the last year

SDN/RX has become SDN 6 and is now merged into Spring Data Neo4j.

That means Spring Boot depending on the Ockham release train will not build anymore.

This adapts Spring Boot 2.4 to the SDN 6

  • It brings automatic configuration for the Bolt Driver under the new namespace spring.neo4j, similar to others (like mongo and redis)
  • Adapts automatic configuration for Spring Data Neo4j

This removes the dependency on Neo4j-OGM as well.

SDN 6 won't have support for bringing up an embedded instance, which is in line with our strategy to recommend Testcontainers or the Neo4j Testharness to our customers and users.

We refrained from adding support for the Neo4j Testharness to the test slices to not broaden the topic more.
However, if we want to help users to bring something up running very fast, that would be an additional option.

The change https://github.com/spring-projects/spring-boot/compare/master...meistermeier:feature/neo4j-starter?expand=1#diff-76ff4fe38f0762e0fcb54986cae8e0b6R1608 is in there to enable SDN 6 for now because the dependency to Spring Data is on Ockham M1 where SDN 6 is not available.

We are looking forward to your feedback.

@wilkinsona
Copy link
Member

Thanks for the PR, @meistermeier.

This looks great but there is quite a lot to take in here. To make it easier to review, I wonder if it would be possible to split it out into separate commits or, ideally, separate pull requests please? For example, the addition of metrics looks great but I think it warrants a separate pull request.

In addition to making things easier for us to review, splitting things up will also make the changes easier to understand if we're reviewing a diff in the future. Perhaps most importantly, separate pull requests will result in a separate entries in the release notes which will hopefully make it easier for users to discover the new features.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jul 10, 2020
@meistermeier
Copy link
Contributor Author

Thanks for your quick response, Andy.
When I saw the changes in the PR, I also thought "wow" and you are right this should get splitted in sensible parts (commits or PRs).
Can wel keep this PR open for the SDN spring-boot starter update? I will go ahead and try to extract driver autoconfig and metrics into different PRs.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 10, 2020
@wilkinsona
Copy link
Member

Can wel keep this PR open for the SDN spring-boot starter update? I will go ahead and try to extract driver autoconfig and metrics into different PRs.

Thanks. That sounds good to me. This PR modified so that it's just for compatibility with the latest Spring Data Ockham snapshots, and then others on top of that to introduce new features.

@meistermeier
Copy link
Contributor Author

So I splitted this up into several PRs but unfortunately they cannot get merged independently :(
Bringing this into an order:
Neo4j Java Driver autoconfig: #22301
Spring Data Neo4j starter (this): #22299
Neo4j Actuator: #22302

Please tell me if I did something terrible wrong during the split :)

@wilkinsona wilkinsona added for: team-attention An issue we'd like other members of the team to review and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Jul 14, 2020
@wilkinsona wilkinsona added this to the 2.4.x milestone Jul 14, 2020
@wilkinsona wilkinsona added the type: enhancement A general enhancement label Jul 14, 2020
Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the PR.

I've made a first pass and that's indeed a lot to take in but this work is super useful to me as I am not familiar with Spring Data Neo4j 6 yet.

I've made quite a lot of comments. Most are formatting and consistency thing that we can easily fix but there are a few that might requite some additional discussion. Can you please have a look to these? Do not hesitate if something isn't clear.

.hasSingleBean(ReactiveCountryRepository.class));
}

@Configuration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency this should have proxyBeanMethods = false.

@AutoConfigureDataNeo4j
@ImportAutoConfiguration
@Import(ReactiveCapableNeo4jVersionAssertion.class)
public @interface ReactiveDataNeo4jTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the other store has a reactive specific variant so I am not keen to introduce that. Perhaps the need of a specific annotation surfaces another problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will target this together with the reactive AutoConfiguration suggestion in the next iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked this one and the reasons why we have chosen to introduce a parallel annotation for reactive is some convenience features:
Fail on database < 4.0 (https://github.com/spring-projects/spring-boot/pull/22299/files/b7fa3d1faca912a7c384ec3c20ca93a8fb3b21a8#diff-31539ed0ee3ec3e7c3a490aaa41e5db5R50)
and setting the spring.data.neo4j.repositories.type to reactive (https://github.com/spring-projects/spring-boot/pull/22299/files/b7fa3d1faca912a7c384ec3c20ca93a8fb3b21a8#diff-31539ed0ee3ec3e7c3a490aaa41e5db5R50)
Arguably this might be too less features for introducing this parallel infrastructure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the other stores have such a variant and I am not keen to introduce it as part of the upgrade. We can reconsider once the upgrade is done of course.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Jul 16, 2020
@meistermeier
Copy link
Contributor Author

Thanks for the detailed feedback. My plan is to resolve the trivial ones first and see how we can align our changes more with the other Spring Data modules in the discussable cases.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 16, 2020
@snicoll snicoll changed the title Update starter for Spring Data Neo4j. Upgrade to Spring Data Neo4j 6 Jul 17, 2020
@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jul 17, 2020
@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Jul 17, 2020
This commit will update the Spring Data Neo4j Spring Boot starter,
autoconfig and actuator.
It will also bring in autoconfiguration for the Neo4j Java driver
to enable users to work with a managed instance of the driver without
the high level abstraction of Spring Data.
Until we decided what to do with the reactive and imperative auto-configuration,
we will keep both. To remove the `@Nested` annotation but keep it readable the
tests get split up into different classes.
@meistermeier meistermeier force-pushed the feature/neo4j-starter branch from a3b2305 to eacfd19 Compare July 28, 2020 10:04
@snicoll snicoll self-assigned this Jul 29, 2020
snicoll pushed a commit to snicoll/spring-boot that referenced this pull request Jul 29, 2020
snicoll added a commit to snicoll/spring-boot that referenced this pull request Jul 29, 2020
snicoll pushed a commit to snicoll/spring-boot that referenced this pull request Jul 29, 2020
snicoll added a commit to snicoll/spring-boot that referenced this pull request Jul 29, 2020
@snicoll snicoll removed the status: waiting-for-feedback We need additional information before we can continue label Jul 29, 2020
@snicoll snicoll modified the milestones: 2.4.x, 2.4.0-M2 Jul 29, 2020
@snicoll snicoll closed this in fdf9310 Jul 29, 2020
@snicoll
Copy link
Member

snicoll commented Jul 29, 2020

@meistermeier @michael-simons, thank you both for helping us upgrade to Spring Data Neo4j 6! For consistency with other stores, I had to undo a number of things in your proposal, see snicoll@9bc71fe for more details.

There's a bit more work still. We need to update the documentation (#22652) and I'd like to experiment supporting the spring.data.neo4j properties again (i.e. the ones used to bootstrap the connection with the client) (#22653)?

@meistermeier meistermeier deleted the feature/neo4j-starter branch July 30, 2020 09:07
@jagadeesh595
Copy link

jagadeesh595 commented Sep 3, 2020

With the latest version of SDN 6.0.0-M2, I have below observation as of now. When we go with either dynamic relationship or Relationship Properties, records are saving in database quickly, but retrieval taking more time compared to Old SDN 5.3.3 version.

In new version, below are the syntaxes to create either dynamic relationship or Relationship Properties,

Syntax for relationship with properties: Below syntax represents Sponsor relationship between two member nodes. MemberSponsor entity contains all relationship properties.

@Relationship(value = "sponsor", direction = Relationship.Direction.OUTGOING)
private Map<Member, MemberSponsor> hasSponsor = new HashMap<>();

Syntax for dynamic relationship without any properties: Below syntax represents Sponsor relationship between two member nodes. In the Map, key-String represents the relationship name, that we can configure dynamically.

@Relationship(direction = Relationship.Direction.OUTGOING)
private Map<String, Member> sponsors = new HashMap<>();

When I am trying to get Member data using below JPA method, system taking more time when any of the above relationships exists in the Member entity class. It is taking 25 mins to get the single Member data using below method from latest version SDN 6.0.0. In old version SDN 5.3.3 – getting same member data within a second. This issue especially occurring only when there is a relationship exists between two nodes with same labels. Here, we are referring relationship between two member nodes of same label.

import org.springframework.data.neo4j.repository.Neo4jRepository;

public interface MemberRepository extends Neo4jRepository<Member, Long> {
    Member findByMemberId(String memberId);
}

Can you please help me on this. Seems like issue with retrieval when there is a Dynamic relationship on entity.

@meistermeier
Copy link
Contributor Author

Thanks @jagadeesh595 for reporting this.
Such problems are better placed in the official issue tracker of Spring Data Neo4j: https://jira.spring.io/projects/DATAGRAPH/
I created a ticket for this problem: https://jira.spring.io/browse/DATAGRAPH-1372

@jagadeesh595
Copy link

Thanks @jagadeesh595 for reporting this.
Such problems are better placed in the official issue tracker of Spring Data Neo4j: https://jira.spring.io/projects/DATAGRAPH/
I created a ticket for this problem: https://jira.spring.io/browse/DATAGRAPH-1372

Thank you for the quick update.

@jagadeesh595

This comment has been minimized.

@snicoll

This comment has been minimized.

@michael-simons

This comment has been minimized.

@jagadeesh595

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants