Nhibernate 在HQL上使用最小值、最大值和计数
hibernate HQL查询是否支持使用select min、max、count和其他sql函数 比如:Nhibernate 在HQL上使用最小值、最大值和计数,nhibernate,hibernate,hql,min,Nhibernate,Hibernate,Hql,Min,hibernate HQL查询是否支持使用select min、max、count和其他sql函数 比如: 从人员p中选择min(p.age) 谢谢支持一些聚合函数:查看是,min()、max()和count()在HQL中受支持 请参阅Hibernate文档。这就是我在Hibernate中使用max的方式: public long getNextId(){ long appId; try{ Session session = HibernateUtil.
从人员p中选择min(p.age)
谢谢支持一些聚合函数:查看是,
min()
、max()
和count()
在HQL中受支持
请参阅Hibernate文档。这就是我在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;
}
请参见主题14.7。链接已更改。你能重新检索页面吗?谢谢谢谢你的提醒。linkfixedi不得不否决这个答案,因为它很快就会被否决。答案给人的印象是,只有这三个功能存在,而其他功能也很多