Daniel Labrosse
Daniel Labrosse

Reputation: 3

Spring Data JDBC not generating derived Query

I am using Spring Data JDBC (v1.1.1) automatically pulled in by SpringBoot 2.2.1.RELEASE. For the repository below, the method should automatically derive the Query at start-up time.

interface AccountRepository extends CrudRepository<Account, Long> {
    long countByLastName(String lastName);
...

Instead I get this..

Caused by: java.lang.IllegalStateException: No query specified on countByLastName
    at org.springframework.data.jdbc.repository.support.JdbcRepositoryQuery.determineQuery(JdbcRepositoryQuery.java:200) ~[spring-data-jdbc-1.1.1.RELEASE.jar:1.1.1.RELEASE]

My entity looks like..

public class Account {

    @Id
    private Long id;
    private final String firstName;
    private final String lastName;

Any idea why I am getting this issue?

Upvotes: 0

Views: 810

Answers (1)

Jens Schauder
Jens Schauder

Reputation: 81988

Support for query derivation for Spring Data JDBC came with version 2.0.0.

Note that query derivation currently only supports properties which get stored in the table of the aggregate root for filtering and sorting.

Upvotes: 1

Related Questions