Lets say I have a Report entity. Inside it there is @Embeddable ReportPeriod which has Integer month and Integer year fields. When i try to sort my Report report by its ReportPeriod reportPeriod it sorts report by month and year. How to change the order of sort (year and then month).开发者_如何学Go Can this be solved by any of the annotations?
I guess you want to load several reports by hibernate criteria and sort them by its embebedded month and year?
Criteria crit = session.createCriteria(Report.class);
crit.addOrder(Order.asc("reportPeriod.year"));
crit.addOrder(Order.asc("reportPeriod.month"));
...=crit.list();
But I am not 100% sure if Order can be applied to an @Embeddable, but is expect it.
加载中,请稍侯......
精彩评论