我正在尝试通过加入我的实体类来创建 BO
Criteria criteria = session.createCriteria(Report.class,"r");
criteria
.createAlias("template", "t")
.createAlias("constituents", "rc")
.createAlias("rc.entity", "pe")
.createAlias("pe.model", "m")
.createAlias("pe.scenario", "s")
.setProjection(Projections.projectionList()
.add( Projections.property("r.Id"))
.add( Projections.property("t.Typ"))
.add( Projections.property("pe.bId"))
.add( Projections.property("m.model"))
.add( Projections.property("s.decay"))
).setMaxResults(100)
.addOrder(Order.asc("r.Id"))
.setResultTransformer(Transformers.aliasToBean(BO.class));
我得到 100 个空 BO,即所有属性都为 null 我的 BO 如下
public class BO implements Serializable {
private static final long serialVersionUID = 1L;
private int Id;
private String Typ;
private String bId;
private String model;
private String decay;
Getters and Setters
......
当我删除行 aliasToBean 并遍历 Object[] 时,我可以看到获取的正确值请指导我...