Open Source Repository

Home /hibernate/hibernate-3.2.6.ga | Repository Home



org/hibernate/criterion/Property.java
//$Id: Property.java 5685 2005-02-12 07:19:50Z steveebersole $
package org.hibernate.criterion;

import java.util.Collection;

/**
 * A factory for property-specific criterion and projection instances
 @author Gavin King
 */
public class Property extends PropertyProjection {
  //private String propertyName;
  protected Property(String propertyName) {
    super(propertyName);
  }

  public Criterion between(Object min, Object max) {
    return Restrictions.between(getPropertyName(), min, max);
  }

  public Criterion in(Collection values) {
    return Restrictions.in(getPropertyName(), values);
  }

  public Criterion in(Object[] values) {
    return Restrictions.in(getPropertyName(), values);
  }

  public SimpleExpression like(Object value) {
    return Restrictions.like(getPropertyName(), value);
  }

  public SimpleExpression like(String value, MatchMode matchMode) {
    return Restrictions.like(getPropertyName(), value, matchMode);
  }

  public SimpleExpression eq(Object value) {
    return Restrictions.eq(getPropertyName(), value);
  }

  public SimpleExpression ne(Object value) {
    return Restrictions.ne(getPropertyName(), value);
  }

  public SimpleExpression gt(Object value) {
    return Restrictions.gt(getPropertyName(), value);
  }

  public SimpleExpression lt(Object value) {
    return Restrictions.lt(getPropertyName(), value);
  }

  public SimpleExpression le(Object value) {
    return Restrictions.le(getPropertyName(), value);
  }

  public SimpleExpression ge(Object value) {
    return Restrictions.ge(getPropertyName(), value);
  }

  public PropertyExpression eqProperty(Property other) {
    return Restrictions.eqPropertygetPropertyName(), other.getPropertyName() );
  }

  public PropertyExpression neProperty(Property other) {
    return Restrictions.nePropertygetPropertyName(), other.getPropertyName() );
  }
  
  public PropertyExpression leProperty(Property other) {
    return Restrictions.lePropertygetPropertyName(), other.getPropertyName() );
  }

  public PropertyExpression geProperty(Property other) {
    return Restrictions.gePropertygetPropertyName(), other.getPropertyName() );
  }
  
  public PropertyExpression ltProperty(Property other) {
    return Restrictions.ltPropertygetPropertyName(), other.getPropertyName() );
  }

  public PropertyExpression gtProperty(Property other) {
    return Restrictions.gtPropertygetPropertyName(), other.getPropertyName() );
  }
  
  public PropertyExpression eqProperty(String other) {
    return Restrictions.eqPropertygetPropertyName(), other );
  }

  public PropertyExpression neProperty(String other) {
    return Restrictions.nePropertygetPropertyName(), other );
  }
  
  public PropertyExpression leProperty(String other) {
    return Restrictions.lePropertygetPropertyName(), other );
  }

  public PropertyExpression geProperty(String other) {
    return Restrictions.gePropertygetPropertyName(), other );
  }
  
  public PropertyExpression ltProperty(String other) {
    return Restrictions.ltPropertygetPropertyName(), other );
  }

  public PropertyExpression gtProperty(String other) {
    return Restrictions.gtPropertygetPropertyName(), other );
  }
  
  public Criterion isNull() {
    return Restrictions.isNull(getPropertyName());
  }

  public Criterion isNotNull() {
    return Restrictions.isNotNull(getPropertyName());
  }

  public Criterion isEmpty() {
    return Restrictions.isEmpty(getPropertyName());
  }

  public Criterion isNotEmpty() {
    return Restrictions.isNotEmpty(getPropertyName());
  }
  
  public CountProjection count() {
    return Projections.count(getPropertyName());
  }
  
  public AggregateProjection max() {
    return Projections.max(getPropertyName());
  }

  public AggregateProjection min() {
    return Projections.min(getPropertyName());
  }

  public AggregateProjection avg() {
    return Projections.avg(getPropertyName());
  }
  
  /*public PropertyProjection project() {
    return Projections.property(getPropertyName());
  }*/

  public PropertyProjection group() {
    return Projections.groupProperty(getPropertyName());
  }
  
  public Order asc() {
    return Order.asc(getPropertyName());
  }

  public Order desc() {
    return Order.desc(getPropertyName());
  }

  public static Property forName(String propertyName) {
    return new Property(propertyName);
  }
  
  /**
   * Get a component attribute of this property
   */
  public Property getProperty(String propertyName) {
    return forNamegetPropertyName() '.' + propertyName );
  }
  
  public Criterion eq(DetachedCriteria subselect) {
    return Subqueries.propertyEqgetPropertyName(), subselect );
  }

  public Criterion ne(DetachedCriteria subselect) {
    return Subqueries.propertyNegetPropertyName(), subselect );
  }

  public Criterion lt(DetachedCriteria subselect) {
    return Subqueries.propertyLtgetPropertyName(), subselect );
  }

  public Criterion le(DetachedCriteria subselect) {
    return Subqueries.propertyLegetPropertyName(), subselect );
  }

  public Criterion gt(DetachedCriteria subselect) {
    return Subqueries.propertyGtgetPropertyName(), subselect );
  }

  public Criterion ge(DetachedCriteria subselect) {
    return Subqueries.propertyGegetPropertyName(), subselect );
  }

  public Criterion notIn(DetachedCriteria subselect) {
    return Subqueries.propertyNotIngetPropertyName(), subselect );
  }

  public Criterion in(DetachedCriteria subselect) {
    return Subqueries.propertyIngetPropertyName(), subselect );
  }

  public Criterion eqAll(DetachedCriteria subselect) {
    return Subqueries.propertyEqAllgetPropertyName(), subselect );
  }

  public Criterion gtAll(DetachedCriteria subselect) {
    return Subqueries.propertyGtAllgetPropertyName(), subselect );
  }

  public Criterion ltAll(DetachedCriteria subselect) {
    return Subqueries.propertyLtAllgetPropertyName(), subselect );
  }

  public Criterion leAll(DetachedCriteria subselect) {
    return Subqueries.propertyLeAllgetPropertyName(), subselect );
  }

  public Criterion geAll(DetachedCriteria subselect) {
    return Subqueries.propertyGeAllgetPropertyName(), subselect );
  }

  public Criterion gtSome(DetachedCriteria subselect) {
    return Subqueries.propertyGtSomegetPropertyName(), subselect );
  }

  public Criterion ltSome(DetachedCriteria subselect) {
    return Subqueries.propertyLtSomegetPropertyName(), subselect );
  }

  public Criterion leSome(DetachedCriteria subselect) {
    return Subqueries.propertyLeSomegetPropertyName(), subselect );
  }

  public Criterion geSome(DetachedCriteria subselect) {
    return Subqueries.propertyGeSomegetPropertyName(), subselect );
  }

}