You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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
The text was updated successfully, but these errors were encountered:
Thank you for the quick response. Why do I need to use latest Spring Boot milestone if DTO projects are declared as implemented in the latest stable version (3.2.4) ?
Hi
I have a domain class Book:
and BookDTO as Java record:
public record BookDTO(String name) {}
Here's my repository:
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:
Spring Boot: 3.2.3
Java: 21
The text was updated successfully, but these errors were encountered: