Hibernate条件查询:投影 分组 聚合 离线查询 子查询
List results = session.createCriteria(Cat.class)
.setProjection( Projections.rowCount() )
.add( Restrictions.eq("color", Color.BLACK) )
.list();
List results = session.createCriteria(Cat.class)
.setProjection( Projections.projectionList()
.add( Projections.rowCount() )
.add( Projections.avg("weight") )
.add( Projections.max("weight") )
.add( Projections.groupProperty("color") )
)
.list();
List results = session.createCriteria(Cat.class)
.setProjection( Projections.alias( Projections.groupProperty("color"), "colr" ) )
.addOrder( Order.asc("colr") )
.list();
List results = session.createCriteria(Cat.class)
.setProjection( Projections.groupProperty("color").as("colr") )
.addOrder( Order.asc("colr") )
.list();
DetachedCriteria dctr = DetachedCriteria.forClass( Affiliate.class );
dctr.setProjection(Property.forName("trackerId"));
dctr.add( Restrictions.like("affiliate", affiliate, MatchMode.ANYWHERE ) );
ctr.add( Subqueries.propertyIn("trackerId", dctr));
» 本文链接:https://blog.apires.cn/archives/1168.html
» 转载请注明来源:Java地带
» 《Hibernate条件查询:投影 分组 聚合 离线查询 子查询》
» 本文章为Java地带整理创作,欢迎转载!转载请注明本文地址,谢谢!
» 部分内容收集整理自网络,如有侵权请联系我删除!
» 订阅本站:https://blog.apires.cn/feed/