Announcement Announcement Module
Collapse
No announcement yet.
custom repository implementation names pattern Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • custom repository implementation names pattern

    Hi,

    I spent an hour debuging a strange problem. Finally the source of all was the internal mechanism that detects the custom repository implementation names. I have a repository UnitRepository and a custom implementation UnitRepositoryCustom with the clas UnitRepositoryImpl. But in my application I also have another repository PoliticalUnitRepository that wasn't related to UnitRepository. AbstractRepositoryConfigDefinitionParser.detectCus tomImplementation() binds the PoliticalUnitRepositoryImpl to UnitRepository. Is this the intended way? In that case the PoliticalUnitRepositoryImpl must extend the UnitRepositoryImpl. Please update the reference documentation with a warning.

    Thank you.

  • #2
    Got the same problem today when I introduced 2 custom implementations for different repositories.
    By debuging I could locate the problem in method AbstractRepositoryConfigDefinitionParser.detectCus tomImplementation(..) where Spring Data tries to find the custom implementation class using a regex pattern .*<RepositoryInterface>Impl

    e.g. if your first interface is named foo.ExampleRepository (with impl class foo.ExampleRepository) and the other interface is called foo.AnotherExampleRepository (with impl class foo.AnotherExampleRepository), for the first interface Spring will find 2 matching implementation classes and will use the first implementation class - but as the matching classes implemetations are collected in a Set it's not defined what is "the first" implementation class.

    I think the regex pattern should not allow any prefix of an exception should be thrown if more than one implementationn classes match the pattern.

    Regards,
    Christian

    Comment

    Working...
    X