是否有可能将SQL的结果映射到非扁平对象?
List<Customer> customers = hibernateSession().createCriteria(CustomerDetailsView.class)
.add(Restrictions.in("userName", userName))
.setProjection(buildProjection())
.setResultTransformer(Transformers.aliasToBean(Customer.class))
.list();
在我的情况下,CustomerDetailsView 是一个扁平的结构。但我需要将它映射到像这样的对象:
public class Customer {
private String userName;
private String title;
private String firstName;
private String lastName;
private String type;
private String companyName;
private AddressDetails addressDetails;
}
并且
public class AddressDetails {
private String countryCode;
private String addressLine1;
private String zipOrPostCode;
private String city;
private String countryDivisionName;
private String countryDivisionCode;
private String countryDivisionTypeCode;
private String residentialAddress;
}
Parent
而不是Child
。如果不是这个问题,你可以在 https://github.com/v-ladynev/fluent-hibernate/issues 上添加一个带有示例的问题。 - v.ladynev