Java Code Examples for org.hibernate.criterion.Restrictions#le()
The following examples show how to use
org.hibernate.criterion.Restrictions#le() .
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: LessEqualOperator.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.sizeLe( queryPath.getPath(), value ); } return Restrictions.le( queryPath.getPath(), args.get( 0 ) ); }
Example 3
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 4
Source File: CriteriaQuery.java From jeewx with Apache License 2.0 | 5 votes |
/** * 设置between(之间)查询条件 * * @param keyname * @param keyvalue1 * @param keyvalue2 */ public void between(String keyname, Object keyvalue1, Object keyvalue2) { Criterion c = null;// 写入between查询条件 if (!keyvalue1.equals(null) && !keyvalue2.equals(null)) { c = Restrictions.between(keyname, keyvalue1, keyvalue2); } else if (!keyvalue1.equals(null)) { c = Restrictions.ge(keyname, keyvalue1); } else if (!keyvalue2.equals(null)) { c = Restrictions.le(keyname, keyvalue2); } criterionList.add(c); }
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(PropertyIsLessThanOrEqualTo filter, Object userData) { String propertyName = getPropertyName(filter.getExpression1()); String finalName = parsePropertyName(propertyName, userData); Object literal = getLiteralValue(filter.getExpression2()); return Restrictions.le(finalName, castLiteral(literal, propertyName)); }
Example 6
Source File: CriteriaQuery.java From jeecg with Apache License 2.0 | 5 votes |
/** * 设置between(之间)查询条件 * * @param keyname * @param keyvalue1 * @param keyvalue2 */ public void between(String keyname, Object keyvalue1, Object keyvalue2) { Criterion c = null;// 写入between查询条件 if (oConvertUtils.isNotEmpty(keyvalue1) && oConvertUtils.isNotEmpty(keyvalue2)) { c = Restrictions.between(keyname, keyvalue1, keyvalue2); } else if (oConvertUtils.isNotEmpty(keyvalue1)) { c = Restrictions.ge(keyname, keyvalue1); } else if (oConvertUtils.isNotEmpty(keyvalue2)) { c = Restrictions.le(keyname, keyvalue2); } criterionList.add(c); }
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: LeRestriction.java From base-framework with Apache License 2.0 | 4 votes |
public Criterion build(String propertyName, Object value) { return Restrictions.le(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; }