如何按标准顺序使用映射列

时间:2011-12-29 13:45:07

标签: hibernate criteria

Criteria criteria = session.createCriteria(Items.class);
criteria.add(Restrictions.eq("itemId", 1003));
criteria.addOrder(Order.desc("category.categoryName"));

此类别是ManyToOne Mapping。 谢谢!

1 个答案:

答案 0 :(得分:0)

Criteria criteria = session.createCriteria(Items.class)
    .add(Restrictions.eq("itemId", 1003))
    .createAlias("category", "category")
    .addOrder(Order.desc("category.categoryName"));