Marcel Overdijk
Marcel Overdijk

Reputation: 11467

Using @RepositoryDefinition and JpaSpecificationExecutor methods doesn't work

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?

Upvotes: 1

Views: 4176

Answers (1)

M. Deinum
M. Deinum

Reputation: 124506

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> {}

Upvotes: 2

Related Questions