FileDocCategorySizeDatePackage
IlikeExpression.javaAPI DocHibernate 3.2.51654Sat Feb 12 00:19:50 GMT 2005org.hibernate.criterion

IlikeExpression

public class IlikeExpression extends Object implements Criterion
A case-insensitive "like"
author
Gavin King

Fields Summary
private final String
propertyName
private final Object
value
Constructors Summary
protected IlikeExpression(String propertyName, Object value)

		this.propertyName = propertyName;
		this.value = value;
	
protected IlikeExpression(String propertyName, String value, MatchMode matchMode)

		this( propertyName, matchMode.toMatchString(value) );
	
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.StringtoSqlString(org.hibernate.Criteria criteria, CriteriaQuery criteriaQuery)

		Dialect dialect = criteriaQuery.getFactory().getDialect();
		String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
		if (columns.length!=1) throw new HibernateException("ilike may only be used with single-column properties");
		if ( dialect instanceof PostgreSQLDialect ) {
			return columns[0] + " ilike ?";
		}
		else {
			return dialect.getLowercaseFunction() + '(" + columns[0] + ") like ?";
		}

		//TODO: get SQL rendering out of this package!
	
public java.lang.StringtoString()

		return propertyName + " ilike " + value;