hibernate
public int getMaxId(Session session) {
String hql = "SELECT MAX(id) FROM ArticleModel";
Query query = session.createQuery(hql);//
int maxid = (int) query.uniqueResult();
return maxid;
}
如果想查最大的数值.直接
SELECT MAX(id) FROM t_customer;
如果想查询最大的id的那一条数据则
SELECT * FROM t_customer WHERE id=(SELECT MAX(id) FROM t_customer);