spring + hibernate 如何使用count(*)

来源:互联网 发布:手机行程软件 编辑:程序博客网 时间:2024/06/14 17:48
 

第一种方法:

spring + hibernate 如何使用count(*) - KILLKISS - KillKissString hql = "select count(*) from User as user";

spring + hibernate 如何使用count(*) - KILLKISS - KillKissInteger count = (Integer)getHibernateTemplate().find(hql).listIterator().next();

spring + hibernate 如何使用count(*) - KILLKISS - KillKissreturn count.intValue();

spring + hibernate 如何使用count(*) - KILLKISS - KillKiss第二种方法:

spring + hibernate 如何使用count(*) - KILLKISS - KillKissString hql = "select count(*) from User as user";

spring + hibernate 如何使用count(*) - KILLKISS - KillKissreturn ((Integer)getHibernateTemplate().iterate(hql).next()).intValue();

spring + hibernate 如何使用count(*) - KILLKISS - KillKiss第三种方法:

spring + hibernate 如何使用count(*) - KILLKISS - KillKissString hql = "select count(*) from User as user";

spring + hibernate 如何使用count(*) - KILLKISS - KillKissQuery query = getHibernateTemplate().createQuery( getSession(),hql);

spring + hibernate 如何使用count(*) - KILLKISS - KillKissreturn ((Integer)query.uniqueResult()).intValue(); 


原创粉丝点击