refreshed criteria doco

git-svn-id: https://svn.jboss.org/repos/hibernate/trunk/Hibernate3/doc@5441 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Gavin King 2005-01-30 15:15:05 +00:00
parent 3f9729bb91
commit 90b9bec988
1 changed files with 11 additions and 6 deletions

View File

@ -241,14 +241,19 @@ List results = session.createCriteria(Cat.class)
</para>
<para>
The projection factory methods allow an alias to optionally be assigned
to a projection, so that it may be referred to in restrictions or orderings.
An alias to optionally be assigned to a projection, so that it may be
referred to in restrictions or orderings.
</para>
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
.setProjection( Projections.alias( Projections.rowCount(), "count" ) )
.add( Restrictions.eq("color", Color.BLACK) )
.list();]]></programlisting>
<programlisting><![CDATA[List results = session.createCriteria(Cat.class)
.setProjection( Projections.projectionList()
.add( Projections.rowCount("catCountByColor") )
.add( Projections.avg("weight", "avgWeight") )
.add( Projections.rowCount(), "catCountByColor" )
.add( Projections.avg("weight"), "avgWeight" )
.add( Projections.max("weight") )
.add( Projections.groupProperty("color") )
)
@ -259,8 +264,8 @@ List results = session.createCriteria(Cat.class)
<programlisting><![CDATA[List results = session.createCriteria(Domestic.class, "cat")
.createAlias("kittens", "kit")
.setProjection( Projections.projectionList()
.add( Projections.property("cat.name", "catName") )
.add( Projections.property("kit.name", "kitName") )
.add( Projections.property("cat.name"), "catName" )
.add( Projections.property("kit.name"), "kitName" )
)
.addOrder( Order.asc("catName") )
.addOrder( Order.asc("kitName") )