I have a native query, and I want to transformer columns (b_id, b_code, b_desc) to complexProperty (a custom object) in ResultDto.
SQL
select a.id as id,
a.name as name,
b.id as b_id,
b.code as b_code,
b.desc as b_desc
from a
left join b
on a.id = b.a_id;
ResultDto.class
public class ResultDto {
private String id;
private String name;
private ComplexPropertyDto complexProperty;
// other fields and getter|setter
}
ComplexPropertyDto.class
public class ComplexPropertyDto {
private String id;
private String code;
private String desc;
// other fields and getter|setter
}
I try use column alias like complexProperty.code and use addScalar("complexProperty.code", StringType.INSTANCE) transformer. But I got org.hibernate.PropertyNotFoundException: Could not resolve PropertyAccess for complexProperty.code on class xxx.ResultDto.
Update
How to transformer columns in table b to property complexProperty in ResultDto.class(work as annotation Embedded).
Maybe it helps somebody. In my case "Could not resolve PropertyAcces" was because for set without get.