Hibernate中直接获取count(*)结果的用法

public boolean isExistRunRota(String rotaid) {
log.debug("find isExistRunRota in RunDuty: ");
boolean isExist=false;
try {
String queryString = "select count(*) from RunDuty as model where model.rotaid=?";
if(([color=red](Long)getHibernateTemplate().find(queryString,rotaid).listIterator().next()).intValue[/color]()>0)
{
isExist=true;
}
return isExist;
} catch (RuntimeException re) {
log.error("find isExistRunRota in RunDuty failed", re);
throw re;
}
}

你可能感兴趣的:(SSH框架)