本文整理匯總了Java中org.hibernate.criterion.Restrictions.gt方法的典型用法代碼示例。如果您正苦於以下問題:Java Restrictions.gt方法的具體用法?Java Restrictions.gt怎麽用?Java Restrictions.gt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.hibernate.criterion.Restrictions
的用法示例。
在下文中一共展示了Restrictions.gt方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: queryComparison
import org.hibernate.criterion.Restrictions; //導入方法依賴的package包/類
private Criterion queryComparison(FieldExpression expression) {
Operator operator = expression.getOperator();
switch (operator) {
case EQUALS:
return Restrictions.eq(getFieldName(expression.getField()), expression.getValue());
case NOT_EQUALS:
return Restrictions.not(Restrictions.like(getFieldName(expression.getField()), expression.getValue()));
case GT:
return Restrictions.gt(getFieldName(expression.getField()), expression.getValue());
case LT:
return Restrictions.lt(getFieldName(expression.getField()), expression.getValue());
default:
return Restrictions.eq(getFieldName(expression.getField()), expression.getValue());
}
}
示例2: getTimeInByIp
import org.hibernate.criterion.Restrictions; //導入方法依賴的package包/類
@Override
public SurveyAnswer getTimeInByIp(SurveyDetail surveyDetail, String ip) {
String surveyId = surveyDetail.getDirId();
Criterion eqSurveyId = Restrictions.eq("surveyId", surveyId);
Criterion eqIp = Restrictions.eq("ipAddr", ip);
int minute = surveyDetail.getEffectiveTime();
Date curdate = new Date();
Calendar calendarDate = Calendar.getInstance();
calendarDate.setTime(curdate);
calendarDate.set(Calendar.MINUTE, calendarDate.get(Calendar.MINUTE)
- minute);
Date date = calendarDate.getTime();
Criterion gtEndDate = Restrictions.gt("endAnDate", date);
return surveyAnswerDao.findFirst("endAnDate", true, eqSurveyId, eqIp,
gtEndDate);
}
示例3: buildCriterion
import org.hibernate.criterion.Restrictions; //導入方法依賴的package包/類
/**
* 按屬性條件參數創建Criterion,輔助函數.
*/
protected Criterion buildCriterion(final String propertyName, final Object propertyValue, final MatchType matchType) {
AssertUtils.hasText(propertyName, "propertyName不能為空");
Criterion criterion = null;
//根據MatchType構造criterion
switch (matchType) {
case EQ:
criterion = Restrictions.eq(propertyName, propertyValue);
break;
case LIKE:
criterion = Restrictions.like(propertyName, (String) propertyValue, MatchMode.ANYWHERE);
break;
case LE:
criterion = Restrictions.le(propertyName, propertyValue);
break;
case LT:
criterion = Restrictions.lt(propertyName, propertyValue);
break;
case GE:
criterion = Restrictions.ge(propertyName, propertyValue);
break;
case GT:
criterion = Restrictions.gt(propertyName, propertyValue);
break;
case NE:
criterion = Restrictions.ne(propertyName, propertyValue);
}
return criterion;
}
示例4: restricions
import org.hibernate.criterion.Restrictions; //導入方法依賴的package包/類
@Override
public void restricions() {
Session ses=null;
//get the session
ses=HibernateUtil.getSession();
System.out.println("\n\tPRICE Less than 500");
//create criteria
Criteria c=ses.createCriteria(product.class);
//create criterion objects for the restriction methods
Criterion lt=Restrictions.lt("price", 500f);
//add restriction to criteria
c.add(lt);
//execute the Criteria
List<product> list=c.list();
//display the list
list.forEach(row->{
System.out.println(row);
});
System.out.println("\n\tPRICE Greater than 500");
Criteria c1=ses.createCriteria(product.class);
Criterion gt=Restrictions.gt("price", 500f);
c1.add(gt);
List<product> list1=c1.list();
list1.forEach(row->{
System.out.println(row);
});
System.out.println("\n\tPRICE Less than or Equal 500");
Criteria c2=ses.createCriteria(product.class);
Criterion le=Restrictions.le("price", 500f);
c2.add(le);
List<product> list2=c2.list();
list2.forEach(row->{
System.out.println(row);
});
System.out.println("\n\tPRICE Greater than or Equal 500");
Criteria c3=ses.createCriteria(product.class);
Criterion ge=Restrictions.ge("price", 500f);
c3.add(ge);
List<product> list3=c3.list();
list3.forEach(row->{
System.out.println(row);
});
Criteria c4=ses.createCriteria(product.class);
Criterion eq=Restrictions.eq("price", 500f);
c4.add(eq);
List<product> list4=c4.list();
System.out.println("\n\tPRICE Equal 500");
list4.forEach(row->{
System.out.println(row);
});
//close the session
HibernateUtil.closeSession(ses);
}
示例5: findNext
import org.hibernate.criterion.Restrictions; //導入方法依賴的package包/類
@Override
public SurveyDirectory findNext(SurveyDirectory directory) {
Date date=directory.getCreateDate();
Criterion criterion=Restrictions.gt("createDate", date);
return surveyDirectoryDao.findFirst(criterion);
}
示例6: buildCriterion
import org.hibernate.criterion.Restrictions; //導入方法依賴的package包/類
/**
* 按屬性條件參數創建Criterion,輔助函數.
*
* @param propertyName
* String
* @param propertyValue
* Object
* @param matchType
* MatchType
* @return Criterion
*/
public static Criterion buildCriterion(String propertyName,
Object propertyValue, MatchType matchType) {
Assert.hasText(propertyName, "propertyName不能為空");
Criterion criterion = null;
// 根據MatchType構造criterion
switch (matchType) {
case EQ:
criterion = Restrictions.eq(propertyName, propertyValue);
break;
case NOT:
criterion = Restrictions.ne(propertyName, propertyValue);
break;
case LIKE:
criterion = Restrictions.like(propertyName, (String) propertyValue,
MatchMode.ANYWHERE);
break;
case LE:
criterion = Restrictions.le(propertyName, propertyValue);
break;
case LT:
criterion = Restrictions.lt(propertyName, propertyValue);
break;
case GE:
criterion = Restrictions.ge(propertyName, propertyValue);
break;
case GT:
criterion = Restrictions.gt(propertyName, propertyValue);
break;
case IN:
criterion = Restrictions.in(propertyName,
(Collection) propertyValue);
break;
case INL:
criterion = Restrictions.isNull(propertyName);
break;
case NNL:
criterion = Restrictions.isNotNull(propertyName);
break;
default:
criterion = Restrictions.eq(propertyName, propertyValue);
break;
}
return criterion;
}