0

我想知道如何在hibernate中制作groupby。我的代码在下面,但它不起作用请告诉我怎么做:

Session session = getSession();
Criteria c = session.createCriteria(CardLog.class);
c.add(Restrictions.ge(CARD_PUNCHING_TIME, todaysDate));
c.setProjection(Projections.groupProperty(USER_ID));
c.addOrder(Order.desc(USER_ID));
cardLogList = c.list();                
System.out.println("----------------" + cardLogList);
4

1 回答 1

0

我认为你必须像这样使用

Session session = getSession();
Criteria c = session.createCriteria(CardLog.class);
c.add(Restrictions.ge("bean property todaydate", todaysDate));
c.setProjection(Projections.groupProperty("bean property userId"));
c.addOrder(Order.desc("bean property userId"));
cardLogList = c.list();                
System.out.println("----------------" + cardLogList);
于 2012-04-14T10:41:23.080 回答