标签:blog io ar java sp for div on log
DetachedCriteria criteria = new RecruitmentCriteria().createForDealer(dealerId, jobTitleId) .dateFilterForSM(year, month) .candidateFilterForSM(candidateId) .finalAssessmentResultPassed().build(); Integer count = (Integer) criteria.getExecutableCriteria(getSession()).uniqueResult(); if(count > 0){
return true;
}
DetachedCriteria构建检索条件时,有两个方法.uniqueResult()与.list(),
采用前者uniqueResult()方法,如果查询结果为1条,则返回值为1;查询结果为0条,则返回0;查询结果大于1条,则抛出异常NonUniqueRequestException.
采用后者list()方法,检索时bibernate会为在底层拼上count(*),因此返回值为0或正整数。
DetachedCriteria类中uniqueResult()方法与list()方法区别
标签:blog io ar java sp for div on log
原文地址:http://www.cnblogs.com/wwawp66/p/4087416.html