Java Code Examples for org.hibernate.criterion.Restrictions#lt()
The following examples show how to use
org.hibernate.criterion.Restrictions#lt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CriteriaUtil.java From ctsms with GNU Lesser General Public License v2.1 | 6 votes |
private static org.hibernate.criterion.Criterion getRestrictionCriterion(RestrictionCriterionTypes restriction, String propertyName, Object value, org.hibernate.type.NullableType type) { if (PROPERTY_NAME_REGEXP.matcher(propertyName).find()) { switch (restriction) { case GT: return Restrictions.gt(propertyName, value); case GE: return Restrictions.ge(propertyName, value); case LT: return Restrictions.lt(propertyName, value); case LE: return Restrictions.le(propertyName, value); default: throw new IllegalArgumentException(MessageFormat.format(UNSUPPORTED_BINARY_RESTRICTION_CRITERION_TYPE, restriction.toString())); } } else { return Restrictions.sqlRestriction(MessageFormat.format(restriction.toString(), propertyName), //" "substr({alias}.logical_path, 1, length(?)) = ?", new Object[] { value }, new org.hibernate.type.NullableType[] { type }); } }
Example 2
Source File: LessThanOperator.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Criterion getHibernateCriterion( QueryPath queryPath ) { Property property = queryPath.getProperty(); if ( property.isCollection() ) { Integer value = QueryUtils.parseValue( Integer.class, args.get( 0 ) ); if ( value == null ) { throw new QueryException( "Left-side is collection, and right-side is not a valid integer, so can't compare by size." ); } return Restrictions.sizeLt( queryPath.getPath(), value ); } return Restrictions.lt( queryPath.getPath(), args.get( 0 ) ); }
Example 3
Source File: SurveyAnswerManagerImpl.java From DWSurvey with GNU Affero General Public License v3.0 | 5 votes |
/** * 取一份卷子回答的数据 */ public Page<SurveyAnswer> answerPage(Page<SurveyAnswer> page,String surveyId){ Criterion cri1=Restrictions.eq("surveyId", surveyId); Criterion cri2=Restrictions.lt("handleState", 2); page.setOrderBy("endAnDate"); page.setOrderDir("desc"); page=findPage(page, cri1, cri2); return page; }
Example 4
Source File: HibernateDao.java From DWSurvey with GNU Affero General Public License v3.0 | 5 votes |
/** * 按属性条件参数创建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; }
Example 5
Source File: CriteriaVisitor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
/** {@inheritDoc} */ @Override public Object visit(PropertyIsLessThan filter, Object userData) { String propertyName = getPropertyName(filter.getExpression1()); String finalName = parsePropertyName(propertyName, userData); Object literal = getLiteralValue(filter.getExpression2()); return Restrictions.lt(finalName, castLiteral(literal, propertyName)); }
Example 6
Source File: CriteriaVisitor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
/** {@inheritDoc} */ @Override public Object visit(Before before, Object extraData) { String propertyName = getPropertyName(before.getExpression1()); String finalName = parsePropertyName(propertyName, before); Object literal = getLiteralValue(before.getExpression2()); if (literal instanceof Date) { return Restrictions.lt(finalName, literal); } else { throw new UnsupportedOperationException("visit(Object userData)"); } }
Example 7
Source File: SQLVisitor.java From DataHubSystem with GNU Affero General Public License v3.0 | 4 votes |
private Criterion internalCriterionComparative( BinaryOperator operator, String property, Object value) { Criterion criterion; switch (operator) { case EQ: { criterion = Restrictions.eq(property, value); break; } case NE: { criterion = Restrictions.ne(property, value); break; } case GT: { criterion = Restrictions.gt(property, value); break; } case GE: { criterion = Restrictions.ge(property, value); break; } case LT: { criterion = Restrictions.lt(property, value); break; } case LE: { criterion = Restrictions.le(property, value); break; } default: throw new UnsupportedOperationException( "Unsupported operation: " + operator.toUriLiteral()); } return criterion; }
Example 8
Source File: LtRestriction.java From base-framework with Apache License 2.0 | 4 votes |
public Criterion build(String propertyName, Object value) { return Restrictions.lt(propertyName, value); }
Example 9
Source File: HibernateUtils.java From lemon with Apache License 2.0 | 2 votes |
/** * 按属性条件参数创建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; }