使用 @RepositoryDe​​finition 和 JpaSpecificationExecutor 方法不起作用 [英] Using @RepositoryDefinition and JpaSpecificationExecutor methods doesn't work

查看:41
本文介绍了使用 @RepositoryDe​​finition 和 JpaSpecificationExecutor 方法不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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.

@RepositoryDe​​finition 存储库是否支持使用 querydsl(或 jpa 规范)谓词感知方法?

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

推荐答案

根据 javadoc

用于划分应为其创建存储库代理的接口的注释.使用 RepositoryDe​​finition 注释接口将导致与扩展 Repository 相同的行为.

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

所以它只支持 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> {}

这篇关于使用 @RepositoryDe​​finition 和 JpaSpecificationExecutor 方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆