Announcement Announcement Module
Collapse
No announcement yet.
Custom JpaRepository causing You have custom methods in interface XX but not provided Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom JpaRepository causing You have custom methods in interface XX but not provided

    I am trying to put some common methods into a "base" interface derived from JpaRepository:

    Code:
    @Transactional
    public interface BaseRepository<T extends BaseModel> extends JpaRepository<T, Long> {
      @Transactional
      public T findByCode(String code);
    }
    Later in my final repository I extend this interface such as:

    Code:
    @Repository("brandRepository")
    @Transactional
    public interface BrandRepository extends BaseRepository<Brand> {
    }
    When I run this code, I get an exception:

    Code:
    Caused by: java.lang.IllegalArgumentException: You have custom methods in interface com.standardset.spring.repository.BrandRepository but not provided a custom implementation!
    	at org.springframework.data.repository.support.RepositoryFactorySupport.validate(RepositoryFactorySupport.java:216)
    	at org.springframework.data.repository.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:130)
    	at org.springframework.data.repository.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:107)
    	at org.springframework.data.repository.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:36)
    I understand that I probably need to provide an implementation for my BaseRepository, however, the findByCode(...) method is a finder that normally is implemented by the JpaRepository architecture, and I am not sure what I should do to make this work.

    Can someone help me out of this jam?

    Thanks.
    -AP_

  • #2
    We have already have a discussion about that:
    http://forum.springsource.org/showth...nd-inheritance

    Comment

    Working...
    X