1

There is an in-memory repository class:

@Repository
interface InMemoryBookRepository extends CrudRepository<Book, String> {
    int countByAuthor(String author);
}

The book model class:

@Value
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@AllArgsConstructor
@KeySpace("books")
class Book {
    @Id
    String id;
    String title;
    String author;
    String isbn;
}

whenever I try to invoke this method an exception is thrown: java.lang.UnsupportedOperationException: Query method not supported. The version of the spring-data-keyvalue is 2.6.4 - the latest one. Any advice?

Reddi
  • 677
  • 6
  • 19
  • Maybe it could help to also share your Book class, Maybe also try out if findByAuthor works as expected – Jonathan May 03 '22 at 11:43
  • Does this answer your question? [Spring Data JPA Redis : Cannot write custom method based query](https://stackoverflow.com/questions/51101829/spring-data-jpa-redis-cannot-write-custom-method-based-query) – Alex May 03 '22 at 12:29

1 Answers1

0

Repositories work with Entity classes. So my guess is, that you should annotate your Book Class with @Entity.

@Value
@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE)
@AllArgsConstructor
@KeySpace("books")
@Entity
class Book {
    @Id
    String id;
    String title;
    String author;
    String isbn;
}