【问题标题】:Hibernate criteria to fetch Data from 3 table's + Sum of a Specific Column and also group by a column name.休眠条件以从 3 个表的 + 特定列的总和中获取数据,并按列名分组。
【发布时间】:2013-12-30 08:55:19
【问题描述】:

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

表 1 表 2 表 3

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

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

【问题讨论】:

    标签: hibernate hibernate-criteria


    【解决方案1】:

    我自己写下了标准,

    列表结果 = 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();
    

    感觉它对像我这样的其他人会有用......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-22
      • 1970-01-01
      • 2016-08-25
      • 2017-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-22
      相关资源
      最近更新 更多