Closed as not planned
Description
Hi
I have a domain class Book:
@Data
@RedisHash("books")
public class Book {
private List<Translation> translations;
@Id
private int id;
private String name;
@Indexed
private int year;
@Indexed
private int pages;
@Indexed
private double price;
private Person author;
@Version
private Integer version;
}
and BookDTO as Java record:
public record BookDTO(String name) {}
Here's my repository:
public interface BookRepository
extends KeyValueRepository<Book, Integer> {
List<BookDTO> findBy();
}
According to the latest Spring Data Redis documentation Java records are allowed as projections:
Java Records are ideal to define DTO types since they adhere to value semantics: All fields are private final and equals(…)/hashCode()/toString() methods are created automatically. Alternatively, you can use any class that defines the properties you want to project.
However when I execute findBy() method I get an error:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [model.Book] to type [projection.BookDTO]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:294)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:185)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:165)
Spring Boot: 3.2.3
Java: 21