Dan*_*xis 6 nhibernate hibernate hql min
hibernate HQL查询是否支持使用select min,max,count和其他sql函数?
喜欢:
select min(p.age) from person p
谢谢
多数民众赞成我如何在Hibernate中使用max:
public long getNextId(){
long appId;
try{
Session session = HibernateUtil.getAdmSessionFactory().getCurrentSession();
Transaction t = session.beginTransaction();
String sequel = "Select max(JAdmAppExemptionId) from JAdmAppExemption";
Query q = session.createQuery(sequel);
List currentSeq = q.list();
if(currentSeq == null){
return appId;
}else{
appId = (Long)currentSeq.get(0);
return appId+1;
}
}catch(Exception exc){
System.out.print("Unable to get latestID");
exc.printStackTrace();
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
43703 次 |
| 最近记录: |