Skip to content
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

Remove o.s.d.annotation.Persistent from the set of identifying annotations. #2133

Closed
K-Lovelace opened this issue Feb 1, 2021 · 3 comments
Closed
Assignees
Labels
type: enhancement A general enhancement

Comments

@K-Lovelace
Copy link

I encountered an issue while working with multiple data sources.
I just upgraded from the old Spring SDN/RX to spring-boot-starter-data-neo4j 2.4.0.
I have multiple data providers from Mongo, and I use Neo4j on the side for other operations non-repositories related.
On my main class, I have the following annotations:

@EnableCaching
@SpringBootApplication
// BEWARE: Point to a non-existent package to avoid having all repositories scanned as Neo4j repositories
@EnableReactiveNeo4jRepositories({"com.example.project.none"})
@EnableReactiveMongoRepositories({"com.example.project.data", "com.example.project.provider.mongo", "com.example.project.provider.parcours"})

If I remove the @EnableReactiveNeo4jRepositories line, every Repository in my project will be marked as Neo4j repository and the build will crash. I do not want to enable neo4j repositories at all, but am forced to make it look in an inexistent package for the project to work.

Is this by design ? Am I missing something obvious ?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 1, 2021
@michael-simons
Copy link
Collaborator

Hi.

Thanks for the report and sorry for the issues.

Can you please share

  • Configuration classes
  • The stack trace(s) of the failing build (I guess you probably mean run)

Thanks.

@K-Lovelace
Copy link
Author

Hi, here is the configuration class: (I hope this is what you wanted) :

@Configuration
@EnableTransactionManagement
public class TxConfig {
    final Driver driver;

    public TxConfig(Driver driver) {
        this.driver = driver;
    }

    @Bean
    public ReactiveTransactionManager reactiveTransactionManager() {
        return new ReactiveNeo4jTransactionManager(driver);
    }
}

And here is the stack trace:

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'parcoursMongoRepository', defined in com.example.project.provider.parcours.ParcoursMongoRepository defined in @EnableReactiveNeo4jRepositories declared on Neo4jReactiveRepositoriesRegistrar.EnableReactiveNeo4jRepositoriesConfiguration, could not be registered. A bean with that name has already been defined in com.example.project.provider.parcours.ParcoursMongoRepository defined in @EnableReactiveMongoRepositories declared on Poi and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

Please let me know if you need anything else.

@michael-simons
Copy link
Collaborator

Hi. I can reproduce the issue. It is somewhat related to spring-projects/spring-boot#25069

While the bean in the Boot issue is not a valid Node, your's is.
That leads to the following scenario that we believe that your repository can be a Neo4j repository. We must do better checks here.

In the mean time, I recommend to set this

spring.data.neo4j.repositories.type=none

It will disable the Neo4j repository but still give you

  • Driver
  • Clients (Imperative / Reactive)
  • Templates (Imperative / Reactive)

@michael-simons michael-simons self-assigned this Feb 2, 2021
@michael-simons michael-simons added type: enhancement A general enhancement and removed blocked: awaiting feedback status: waiting-for-triage An issue we've not yet triaged labels Feb 2, 2021
@michael-simons michael-simons added this to the 6.0.4 (2020.0.4) milestone Feb 2, 2021
@michael-simons michael-simons changed the title Neo4jReactiveRepositories enabled by default Remove o.s.d.annotation.Persistent from the set of identifying annotations. Feb 2, 2021
michael-simons added a commit that referenced this issue Feb 2, 2021
…fying annotations.

This removes `@Persistent` from the set that is used as so called
identifying annotations inside the repository configuration.

This change makes the process of identifying a repository as Neo4j
repository more strict: While it doesn't change anything in a single
store scenario - repository is selected by the entity being managed and
that is still `@Persistent` - it will fix missidentifying a repository
of another store as elligable for being a Neo4j repository.

This fixes #2133.
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

No branches or pull requests

3 participants