使用 @RepositoryDefinition 和 JpaSpecificationExecutor 方法不起作用 [英] Using @RepositoryDefinition and JpaSpecificationExecutor methods doesn't work
问题描述
我有一个 Spring Data 存储库类,例如:
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);
}
标准的 crud 方法确实有效,但是 findAll(来自 JpaSpecificationExecutor)不起作用.
The standard crud methods do work, however the findAll (from JpaSpecificationExecutor) doesn't work.
@RepositoryDefinition
存储库是否支持使用 querydsl(或 jpa 规范)谓词感知方法?
Do @RepositoryDefinition
repositories support using the querydsl (or jpa specification) predicate-aware methods?
推荐答案
根据 javadoc
用于划分应为其创建存储库代理的接口的注释.使用 RepositoryDefinition
注释接口将导致与扩展 Repository
相同的行为.
Annotation to demarcate interfaces a repository proxy shall be created for. Annotating an interface with
RepositoryDefinition
will cause the same behaviour as extendingRepository
.
所以它只支持 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> {}
这篇关于使用 @RepositoryDefinition 和 JpaSpecificationExecutor 方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!