使用Hibernate准则投影到列表字段

时间:2018-04-25 10:15:30

标签: java hibernate criteria hibernate-criteria

我有一个像这样的POJO

Class BillEntity {
      private int id;
      private double amount;
      private List<Integer> paymentIds;
}

我想使用Hibernate标准从数据库中获取此Object,目前我的代码是这样的

DetachedCriteria criteria = DetachedCriteria.forClass(Bill.class);
//some Join aliases, which are working as expected
criteria.setProjection(Projections.projectionList()
        .add(Projections.property("id") , "id")
        .add(Projections.property("amount") , "amount");

criteria.setResultTransformer(new AliasToBeanResultTransformer(BillEntity.class));
criteria.list();

idamount已正确填充,但我不确定如何填充paymentIds

赞赏任何指针!

0 个答案:

没有答案