本文整理了Java中javax.jdo.Query.setGrouping
方法的一些代码示例,展示了Query.setGrouping
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setGrouping
方法的具体详情如下:
包路径:javax.jdo.Query
类名称:Query
方法名:setGrouping
[英]Set the grouping expressions, optionally including a "having" clause. When grouping is specified, each result expression must either be an expression contained in the grouping, or an aggregate evaluated once per group.
[中]设置分组表达式,可选地包括“having”子句。指定分组时,每个结果表达式必须是分组中包含的表达式,或者是每个组计算一次的聚合。
代码示例来源:origin: org.apache.continuum/continuum-store
public Map<Integer, ProjectGroupSummary> getProjectsSummary()
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( Project.class );
Query query = pm.newQuery( extent );
query.setResult( "projectGroup.id as projectGroupId, state as projectState, count(state) as size" );
query.setResultClass( ProjectSummaryResult.class );
query.setGrouping( "projectGroup.id, state" );
List<ProjectSummaryResult> results = (List<ProjectSummaryResult>) query.execute();
Map<Integer, ProjectGroupSummary> summaries = processProjectGroupSummary( results );
tx.commit();
return summaries;
}
finally
{
rollback( tx );
}
}
代码示例来源:origin: tzaeschke/zoodb
q.setGrouping("dept.name having count(dept.name) > 1");
Collection<Object[]> results = (Collection<Object[]>)q.execute();
Iterator<Object[]> it = results.iterator();
内容来源于网络,如有侵权,请联系作者删除!