Results 1 to 2 of 2

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

  1. #1
    Join Date
    May 2011
    Posts
    16

    Default 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. #2
    Join Date
    Apr 2011
    Posts
    107

    Default

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •