Hibernate标准orderby

时间:2012-08-10 05:04:33

标签: hibernate criteria

 Criteria crit=hbSession.createCriteria(S1.class)
.add(Restrictions.between("s1Docdt",startDate, endDate))
.add(Restrictions.eq("s1BranchCode",branchCode))    
.add(Restrictions.eq("s1AccountingYear",year));
 crit.addOrder(Order.asc("s1Docdt","s1Dcno","s1Tc");

我创建了一个会话并试图添加限制并收到错误,所以任何人都可以帮助我。

1 个答案:

答案 0 :(得分:0)

相应于Hibernate Javadoc Order.asc(String)方法,你的代码对我来说似乎不对。试试这个:

Criteria crit = hbSession.createCriteria(S1.class)
    .add(Restrictions.between("s1Docdt",startDate, endDate))
    .add(Restrictions.eq("s1BranchCode",branchCode))    
    .add(Restrictions.eq("s1AccountingYear",year));
crit.addOrder(Order.asc("s1Docdt"));
crit.addOrder(Order.asc("s1Dcno"));
crit.addOrder(Order.asc("s1Tc"));

希望这有帮助。