我有一个本机查询,我想将列 ( b_id
, b_code
, b_desc
) 转换complexProperty
为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
}
我尝试使用列别名complexProperty.code
并使用addScalar("complexProperty.code", StringType.INSTANCE)
转换器。但我得到了org.hibernate.PropertyNotFoundException: Could not resolve PropertyAccess for complexProperty.code on class xxx.ResultDto
。
更新
如何将表中的列转换b
为属性(作为注释)。complexProperty
ResultDto.class
Embedded