Spring Data JPA
  1. Spring Data JPA
  2. DATAJPA-234

Issue with "adding custom behaviour to all repositories" in spring data jpa

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Works as Designed
    • Affects Version/s: 1.1 GA
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Java6 + Spring Roo

      Description

      I systematically get the following exception:

      Could  not instantiate bean class [trc.suivi.repository.GlobalRepositoryImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: trc.suivi.repository.GlobalRepositoryImpl.<i
      nit>()
      

      Further info available on the forum.

        Activity

        Hide
        Oliver Gierke added a comment - - edited

        So that seems to be a bug in your code, right? A few things to check here:

        1. It seems that GlobalRepositoryImpl is being considered by the Spring Data infrastructure as custom implementation class for GlobalRepository (read up on why this is the case in the reference documentation).
        2. The observation in 1. probably originates from the GlobalRepository interface being considered a dedicated user repository definition you'd like to get repository instances created for. This is actually not the case as it's pretty much your common base interface all your actual repository interfaces shall refer to. Which leads me to the assumption that you …
        3. didn't read the reference docs on how to extend all repositories carefully as the note under the very first example of the linked chapter explains why you want to annotate the intermediate interface with @NoRepositoryBean. Doing that should solve your problem.

        Show
        Oliver Gierke added a comment - - edited So that seems to be a bug in your code, right? A few things to check here: 1. It seems that GlobalRepositoryImpl is being considered by the Spring Data infrastructure as custom implementation class for GlobalRepository (read up on why this is the case in the reference documentation ). 2. The observation in 1. probably originates from the GlobalRepository interface being considered a dedicated user repository definition you'd like to get repository instances created for. This is actually not the case as it's pretty much your common base interface all your actual repository interfaces shall refer to. Which leads me to the assumption that you … 3. didn't read the reference docs on how to extend all repositories carefully as the note under the very first example of the linked chapter explains why you want to annotate the intermediate interface with @NoRepositoryBean . Doing that should solve your problem.
        Hide
        Julien Martin added a comment -

        Oliver,
        I am so sorry. It was indeed a bug on my side.
        Thanks a lot for the detailed explanation. I understand much better now.
        Regards,
        Julien.

        Show
        Julien Martin added a comment - Oliver, I am so sorry. It was indeed a bug on my side. Thanks a lot for the detailed explanation. I understand much better now. Regards, Julien.
        Hide
        Oliver Gierke added a comment -

        No problem, glad it works out for you!

        Show
        Oliver Gierke added a comment - No problem, glad it works out for you!

          People

          • Assignee:
            Oliver Gierke
            Reporter:
            Julien Martin
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: