0

我需要创建类似于

select obj, obj.prop.id from Object1 obj group by obj.prop.id

怎么做?

4

1 回答 1

3

参考示例http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/querycriteria.html#querycriteria-projection

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();
于 2012-09-11T08:54:00.767 回答