如何在hibernate中实现 如下 sql 语句: select * from table1 order by col1+col2 desc;

其中 col1 和col2 为 table1 中两个为number 类型的字段。
2024-12-04 09:47:03
推荐回答(3个)
回答1:

该类继承DaoActionSupport类
1.
String hql = "select c from Table(实体名称) c order by col1+col2 desc";
getHibernateTemplate().find(hql);
2.
Criteria criteria = this.getSession.createCriteria(Table.class);
criteria.addOrder(Order.desc(col1+col2));
criteria.list();

回答2:

from Teacher t order by t.age,t.salary desc

回答3:

from table1 order by col1+col2 desc;