Package org.hibernate

Interface Criteria

  • All Superinterfaces:

    public interface Criteria
    extends CriteriaSpecification
    Criteria is a simplified API for retrieving entities by composing Criterion objects. This is a very convenient approach for functionality like "search" screens where there is a variable number of conditions to be placed upon the result set.

    The Session is a factory for Criteria. Criterion instances are usually obtained via the factory methods on Restrictions. eg.
     List cats = session.createCriteria(Cat.class)
         .add("name", "Iz%") )
         .add( "weight", new Float(minWeight) ) )
         .addOrder( Order.asc("age") )
    You may navigate associations using createAlias() or createCriteria().
     List cats = session.createCriteria(Cat.class)
             .add("name", "Iz%") )
     List cats = session.createCriteria(Cat.class)
         .createAlias("kittens", "kit")
         .add("", "Iz%") )
    You may specify projection and aggregation using Projection instances obtained via the factory methods on Projections.
     List cats = session.createCriteria(Cat.class)
         .setProjection( Projections.projectionList()
             .add( Projections.rowCount() )
             .add( Projections.avg("weight") )
             .add( Projections.max("weight") )
             .add( Projections.min("weight") )
             .add( Projections.groupProperty("color") )
         .addOrder( Order.asc("color") )
    See Also:
    SharedSessionContract.createCriteria(java.lang.Class), Restrictions, Projections, Order, Criterion, Projection, a disconnected version of this API