public int getLastEmpId() {
String hql = "select max(empid) from Emp";
return
((Long)sessionFactory.getCurrentSession().createQuery(hql).uniqueResult()).intValue();
}
但是测试不成功的。。。求高手解答。。
...全文
3503打赏收藏
hibernate中hql怎么查询到最后一条记录
有一个emp表。。。empid是int型主键,是自增的。。我现在要用hql语句 查询到最后一条记录的empid是什么 怎么去写? 我写的是public int getLastEmpId() { String hql = "select max(empid) from Emp"; return ((Long)sessionFactory.getCurrentSession().createQuery(hql).uniqueResult()).intValue(); } 但是测试不成功的。。。求高手