FileDocCategorySizeDatePackage
Order.javaAPI DocHibernate 3.2.52063Fri Jul 15 11:52:10 BST 2005org.hibernate.criterion

Order

public class Order extends Object implements Serializable
Represents an order imposed upon a Criteria result set
author
Gavin King

Fields Summary
private boolean
ascending
private boolean
ignoreCase
private String
propertyName
Constructors Summary
protected Order(String propertyName, boolean ascending)
Constructor for Order.

		this.propertyName = propertyName;
		this.ascending = ascending;
	
Methods Summary
public static org.hibernate.criterion.Orderasc(java.lang.String propertyName)
Ascending order

param
propertyName
return
Order

		return new Order(propertyName, true);
	
public static org.hibernate.criterion.Orderdesc(java.lang.String propertyName)
Descending order

param
propertyName
return
Order

		return new Order(propertyName, false);
	
public org.hibernate.criterion.OrderignoreCase()

		ignoreCase = true;
		return this;
	
public java.lang.StringtoSqlString(org.hibernate.Criteria criteria, CriteriaQuery criteriaQuery)
Render the SQL fragment

		String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
		Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName);
		StringBuffer fragment = new StringBuffer();
		for ( int i=0; i<columns.length; i++ ) {
			SessionFactoryImplementor factory = criteriaQuery.getFactory();
			boolean lower = ignoreCase && type.sqlTypes( factory )[i]==Types.VARCHAR;
			if (lower) {
				fragment.append( factory.getDialect().getLowercaseFunction() )
					.append('(");
			}
			fragment.append( columns[i] );
			if (lower) fragment.append(')");
			fragment.append( ascending ? " asc" : " desc" );
			if ( i<columns.length-1 ) fragment.append(", ");
		}
		return fragment.toString();
	
public java.lang.StringtoString()

		return propertyName + ' " + (ascending?"asc":"desc");