本文整理匯總了Java中org.hibernate.criterion.Restrictions.between方法的典型用法代碼示例。如果您正苦於以下問題:Java Restrictions.between方法的具體用法?Java Restrictions.between怎麽用?Java Restrictions.between使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.criterion.Restrictions
的用法示例。
在下文中一共展示了Restrictions.between方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: count
import org.hibernate.criterion.Restrictions; //導入方法依賴的package包/類
@SuppressWarnings("nls")
@Override
public long count(String freetext, Date[] dates, String userId, Institution institution)
{
Criterion dateRestriction = null;
if( dates != null )
{
Date start = dates[0];
Date end = dates[1];
if( start != null && end != null ) // BETWEEN and ON
{
dateRestriction = Restrictions.between("dateModified", start, end);
}
else if( start != null && end == null ) // AFTER
{
dateRestriction = Restrictions.ge("dateModified", start);
}
else if( start == null && end != null ) // BEFORE
{
dateRestriction = Restrictions.le("dateModified", end);
}
}
if( dateRestriction != null )
{
return countByCriteria(Restrictions.eq("owner", userId), Restrictions.eq("institution", institution),
dateRestriction, Restrictions.ilike("name", "%" + freetext + "%"));
}
else
{
return countByCriteria(Restrictions.eq("owner", userId), Restrictions.eq("institution", institution),
Restrictions.ilike("name", "%" + freetext + "%"));
}
}