Hibernate标准从3个表中获取数据+特定列的总和,并按列名分组。

时间:2013-12-12 04:39:30

标签: hibernate hibernate-criteria

我想使用Hibernate标准从3个表中获取数据+特定列的总和,并按列名分组。

表1 表2 表3

1。)选择表1,表2,表3中的一些列 2.)特定列的总和 3.)在特定列上分组

如果我可以为此编写Criteria将会很有帮助。

1 个答案:

答案 0 :(得分:0)

我自己写下了标准,

列出结果= session.createCriteria(Table1.class)

.createAlias("Table2", "Tb2")
.createAlias("Table3", "Tb3")
.add( Restrictions.eqProperty("Tb2.someColumn", "some Property from Model") )
 .setProjection( Projections.projectionList()
     .add( Projections.avg("someproperty") )
    .add( Projections.max("someproperty") )
    .add( Projections.groupProperty("someproperty") )
)
.list();

感觉像对我这样的人有用......