Spring Data Neo4j
  1. Spring Data Neo4j
  2. DATAGRAPH-326

GraphRepositoryFactory picks up more than just GraphRepository repositories

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.1
    • Fix Version/s: None
    • Component/s: CORE
    • Labels:
      None

      Description

      If you have different types of Spring Data Repositories in the same package, like a JPARepository and a GraphRepository and say one for Spring Data Mongo. Then the GraphRepositoryFactory, if base-package is set to this package, will pick them all up thinking they are all GraphRepositorys.

      Any scan should only pick up GraphRepository interfaces and ignore any other classes in the same package.

      If it does scan others, then in line 86 on GraphRepositoryFactory will get a domain object that isn't a SDN domain object.

      Maybe need to call getRepository method of base class RepositoryFactorySupport in the getTargetRepository method???

      Or maybe it needs to catch this much earlier. Not sure which BeanPostProcessor is used that goes into the base package and searches for repositories.

        Activity

        Hide
        Oliver Gierke added a comment -

        This works as designed. In general, repository interfaces do not have to extend a store specific repository interface. So the classpath scanning picks up everything that is extending Repository or annotation with @RepositoryDefinition. To work around this, use nested <context:exclude-filter /> elements or the according annotations in case you're using JavaConfig.

        Show
        Oliver Gierke added a comment - This works as designed. In general, repository interfaces do not have to extend a store specific repository interface. So the classpath scanning picks up everything that is extending Repository or annotation with @RepositoryDefinition . To work around this, use nested <context:exclude-filter /> elements or the according annotations in case you're using JavaConfig.
        Hide
        Mark Spritzler added a comment -

        OK, just saw that exclude-filer can be used between <jpa:repositories> and <neo4j:repositories>

        The reason I was worried is that if I had had an exclude-filter in say a component-scan, then having a multi-store databases with repositories of each kind wouldn't work.

        Right now, I am just using different subpackages for the difference Spring Data repositories for different stores.

        Thanks Oliver.

        I will update the documentation of Neo4J in the section on neo4j-repository configuration to say that you can include the two filters, just for others later down the road that come across this "feature" works as designed.

        You can close this issue.

        Mark

        Show
        Mark Spritzler added a comment - OK, just saw that exclude-filer can be used between <jpa:repositories> and <neo4j:repositories> The reason I was worried is that if I had had an exclude-filter in say a component-scan, then having a multi-store databases with repositories of each kind wouldn't work. Right now, I am just using different subpackages for the difference Spring Data repositories for different stores. Thanks Oliver. I will update the documentation of Neo4J in the section on neo4j-repository configuration to say that you can include the two filters, just for others later down the road that come across this "feature" works as designed. You can close this issue. Mark
        Hide
        Oliver Gierke added a comment -

        Thanks, Mark. Feel free to refer to this issue in the pull request you're submitting. I'll keep it open until then.

        Show
        Oliver Gierke added a comment - Thanks, Mark. Feel free to refer to this issue in the pull request you're submitting. I'll keep it open until then.

          People

          • Assignee:
            Michael Hunger
            Reporter:
            Mark Spritzler
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: