Closed as not planned
Closed as not planned
Description
When a Spring Data JPA query returns a view (interface or just a single property), it is now required that converted properties provide a redundant constructor with their own class as parameter. E.g.
public interface DemoRepository extends JpaRepository<DemoEntity, Long> {
@Query("SELECT e.valueObject1 FROM DemoEntity e")
DemoValueObject1 findFirstValueObject1();
}
the DemoValueObject1
(mapped by an AttributeConverter
to string) needs such a really redundant ctor:
public class DemoValueObject1 {
private String value;
public DemoValueObject1(DemoValueObject1 value) {
this.value = value.getValue();
}
}
otherwise it fails with
org.hibernate.query.SemanticException: Missing constructor for type 'DemoValueObject2' [SELECT new com.example.demo.DemoValueObject2(e.valueObject2) FROM DemoEntity e]
Here is the full minimal sample application to reproduce it:
https://github.com/hirth-abi/spring_boot_353_2/blob/main/src/test/java/com/example/demo/DemoRepositoryTest.java
Tested with Spring Boot 3.5.3, this was not required in Spring Boot 3.4.