LikeExpressionpublic class LikeExpression extends Object implements CriterionA criterion representing a "like" expression |
Fields Summary |
---|
private final String | propertyName | private final Object | value | private final Character | escapeChar | private final boolean | ignoreCase |
Constructors Summary |
---|
protected LikeExpression(String propertyName, String value, Character escapeChar, boolean ignoreCase)
this.propertyName = propertyName;
this.value = value;
this.escapeChar = escapeChar;
this.ignoreCase = ignoreCase;
| protected LikeExpression(String propertyName, String value)
this( propertyName, value, null, false );
| protected LikeExpression(String propertyName, String value, MatchMode matchMode)
this( propertyName, matchMode.toMatchString( value ) );
| protected LikeExpression(String propertyName, String value, MatchMode matchMode, Character escapeChar, boolean ignoreCase)
this( propertyName, matchMode.toMatchString( value ), escapeChar, ignoreCase );
|
Methods Summary |
---|
public org.hibernate.engine.TypedValue[] | getTypedValues(org.hibernate.Criteria criteria, CriteriaQuery criteriaQuery)
return new TypedValue[] {
criteriaQuery.getTypedValue( criteria, propertyName, value.toString().toLowerCase() )
};
| public java.lang.String | toSqlString(org.hibernate.Criteria criteria, CriteriaQuery criteriaQuery)
Dialect dialect = criteriaQuery.getFactory().getDialect();
String[] columns = criteriaQuery.getColumnsUsingProjection( criteria, propertyName );
if ( columns.length != 1 ) {
throw new HibernateException( "Like may only be used with single-column properties" );
}
String lhs = ignoreCase
? dialect.getLowercaseFunction() + '(" + columns[0] + ')"
: columns[0];
return lhs + " like ?" + ( escapeChar == null ? "" : " escape \'" + escapeChar + "\'" );
|
|