Java Code Examples for org.hibernate.criterion.Restrictions#sqlRestriction()
The following examples show how to use
org.hibernate.criterion.Restrictions#sqlRestriction() .
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: CriteriaUtil.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
private static org.hibernate.criterion.Criterion getRestrictionCriterion(RestrictionCriterionTypes restriction, String propertyName) { if (PROPERTY_NAME_REGEXP.matcher(propertyName).find()) { switch (restriction) { case IS_NULL: return Restrictions.isNull(propertyName); case IS_NOT_NULL: return Restrictions.isNotNull(propertyName); default: throw new IllegalArgumentException(MessageFormat.format(UNSUPPORTED_UNARY_RESTRICTION_CRITERION_TYPE, restriction.toString())); } } else { return Restrictions.sqlRestriction(MessageFormat.format(restriction.toString(), propertyName)); } }
Example 3
Source File: NotTokenOperator.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Criterion getHibernateCriterion( QueryPath queryPath ) { String value = caseSensitive ? getValue( String.class ) : getValue( String.class ).toLowerCase(); return Restrictions.sqlRestriction( "c_." + queryPath.getPath() + " !~* '" + TokenUtils.createRegex( value ) + "' " ); }
Example 4
Source File: TokenOperator.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Criterion getHibernateCriterion( QueryPath queryPath ) { String value = caseSensitive ? getValue( String.class ) : getValue( String.class ).toLowerCase(); return Restrictions.sqlRestriction( "c_." + queryPath.getPath() + " ~* '" + TokenUtils.createRegex( value ) + "'" ); }