【发布时间】:2013-12-30 08:55:19
【问题描述】:
我想使用 Hibernate 标准从 3 个表的 + 特定列的总和中获取数据,并按列名分组。
表 1 表 2 表 3
1.) 选择表 1、表 2、表 3 中的一些列 2.) 特定列的总和 3.) 在特定列上分组
如果我能为此编写 Criteria 将会很有帮助。
【问题讨论】:
标签: hibernate hibernate-criteria
我想使用 Hibernate 标准从 3 个表的 + 特定列的总和中获取数据,并按列名分组。
表 1 表 2 表 3
1.) 选择表 1、表 2、表 3 中的一些列 2.) 特定列的总和 3.) 在特定列上分组
如果我能为此编写 Criteria 将会很有帮助。
【问题讨论】:
标签: hibernate hibernate-criteria
我自己写下了标准,
列表结果 = 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();
感觉它对像我这样的其他人会有用......
【讨论】: