Using @RepositoryDefinition and JpaSpecificationExecutor methods doesn't work

…衆ロ難τιáo~ 提交于 2019-12-12 05:28:39

问题


I'm having a Spring Data repository class like:

@RepositoryDefinition(domainClass = Book.class, idClass = Long.class)
public interface BookRepository {

    List<Book> findAll();

    List<Book> findByOrderByPublishDateDesc();

    Book findOne(Long id);

    Book save(Book book);

    boolean exists(Long id);

    void delete(Long id);

    Iterable<Book> findAll(Predicate predicate, OrderSpecifier<?>... orders);
}

The standard crud methods do work, however the findAll (from JpaSpecificationExecutor) doesn't work.

Do @RepositoryDefinition repositories support using the querydsl (or jpa specification) predicate-aware methods?


回答1:


According the javadoc

Annotation to demarcate interfaces a repository proxy shall be created for. Annotating an interface with RepositoryDefinition will cause the same behaviour as extending Repository.

So it only supports the basic set available on Repository (at least that is what I deduce from the docs). If you want more you probably have to extend the specific interface next to adding the annotation.

@RepositoryDefinition(domainClass = Book.class, idClass = Long.class)
public interface BookRepository extends JpaSpecificationExecutor<Book> {}


来源:https://stackoverflow.com/questions/29026755/using-repositorydefinition-and-jpaspecificationexecutor-methods-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!