From: <one...@us...> - 2003-03-01 13:02:23
|
Update of /cvsroot/hibernate/Hibernate2/doc/reference/src In directory sc8-pr-cvs1:/tmp/cvs-serv24856/doc/reference/src Modified Files: query_language.xml Log Message: fixed error in example Index: query_language.xml =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/doc/reference/src/query_language.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** query_language.xml 23 Feb 2003 13:53:24 -0000 1.3 --- query_language.xml 1 Mar 2003 13:02:19 -0000 1.4 *************** *** 53,66 **** <programlisting><![CDATA[select cat.mate from cat in class eg.Cat]]></programlisting> ! <para>You may even select collection elements:</para> ! <programlisting><![CDATA[select cat.kittens.elements from cat in class eg.Cat]]></programlisting> <para> ! Queries may return properties any value type including properties of component type: </para> <programlisting><![CDATA[select cat.name from cat in class eg.DomesticCat ! where cat.name like 'fri%']]></programlisting> <para> --- 53,71 ---- <programlisting><![CDATA[select cat.mate from cat in class eg.Cat]]></programlisting> ! <para> ! You may even select collection elements, using the special <literal>elements</literal> ! function. The following query returns all kittens of any cat. ! </para> ! <programlisting><![CDATA[select elements(cat.kittens) from cat in class eg.Cat]]></programlisting> <para> ! Queries may return properties of any value type including properties of component type: </para> <programlisting><![CDATA[select cat.name from cat in class eg.DomesticCat ! where cat.name like 'fri%' ! ! select cust.name.firstName from cust in class Customer]]></programlisting> <para> *************** *** 71,75 **** <programlisting><![CDATA[select mother, offspr from mother in class eg.DomesticCat, offspr in class eg.Cat ! where offspr in mother.kittens.elements ]]></programlisting> <para> --- 76,80 ---- <programlisting><![CDATA[select mother, offspr from mother in class eg.DomesticCat, offspr in class eg.Cat ! where offspr in elements(mother.kittens)]]></programlisting> <para> *************** *** 81,85 **** from cat in class eg.Cat ! select cat, count(cat.kittens.elements) from cat in class eg.Cat group by cat]]></programlisting> <para> --- 86,90 ---- from cat in class eg.Cat ! select cat, count( elements(cat.kittens) ) from cat in class eg.Cat group by cat]]></programlisting> <para> *************** *** 148,156 **** <programlisting><![CDATA[select kitten from cat in class eg.Cat, ! kitten in cat.kittens.elements]]></programlisting> <para> ! The <literal>elements</literal> construct is like a special property referring to the ! element set of the collection. </para> </sect1> --- 153,160 ---- <programlisting><![CDATA[select kitten from cat in class eg.Cat, ! kitten in elements(cat.kittens)]]></programlisting> <para> ! The <literal>elements</literal> function accesses element set of the collection. </para> </sect1> *************** *** 363,384 **** <para> ! The SQL functions <literal>any, some, all, exists, in</literal> are supported when passed one of ! two special properties of a collection. The special properties are <literal>elements</literal> and ! <literal>indices</literal>. Respectively they represent the element set and the index set of the ! collection. </para> <programlisting><![CDATA[select mother from mother in class eg.Cat, kit in class eg.Cat ! where kit in foo.kittens.elements select p from list in class eg.NameList, p in class eg.Person ! where p.name = some list.names.elements ! from cat in class eg.Cat where exists cat.kittens.elements ! from p in class eg.Player where 3 > all p.scores.elements from show in class eg.Show ! where 'fizard' in show.acts.indices]]></programlisting> <para> --- 367,395 ---- <para> ! There are also functional forms (which, unlike the constructs above, are not case sensitive): ! </para> ! ! <programlisting><![CDATA[from order in class Order where maxindex(order.items) > 100 ! ! from order in class Order where size(order.items) > 100]]></programlisting> ! ! <para> ! The SQL functions <literal>any, some, all, exists, in</literal> are supported when passed the element ! or index set of a collection (<literal>elements</literal> and <literal>indices</literal> functions) ! or the result of a subquery (see below). </para> <programlisting><![CDATA[select mother from mother in class eg.Cat, kit in class eg.Cat ! where kit in elements(foo.kittens) select p from list in class eg.NameList, p in class eg.Person ! where p.name = some elements(list.names) ! from cat in class eg.Cat where exists elements(cat.kittens) ! from p in class eg.Player where 3 > all elements(p.scores) from show in class eg.Show ! where 'fizard' in indices(show.acts)]]></programlisting> <para> *************** *** 423,427 **** select item from item in class Item, order in class Order ! where order.items[order.items.maxIndex] = item and order.id = 11]]></programlisting> <para> --- 434,438 ---- select item from item in class Item, order in class Order ! where order.items[ maxindex(order.items) ] = item and order.id = 11]]></programlisting> <para> *************** *** 429,432 **** --- 440,446 ---- </para> + <programlisting><![CDATA[select item from item in class Item, order in class Order + where order.items[ size(order.items) - 1 ] = item]]></programlisting> + <para> Scalar SQL functions supported by the underlying database may be used *************** *** 446,450 **** where prod.name = 'widget' and store.location.name in ( 'Melbourne', 'Sydney' ) ! and prod = all cust.currentOrder.lineItems.elements]]></programlisting> <para> --- 460,464 ---- where prod.name = 'widget' and store.location.name in ( 'Melbourne', 'Sydney' ) ! and prod = all elements(cust.currentOrder.lineItems)]]></programlisting> <para> *************** *** 500,504 **** group by cat.color ! select foo.id, avg(foo.names.elements), max(foo.names.indices) from foo in class eg.Foo group by foo.id]]></programlisting> --- 514,518 ---- group by cat.color ! select foo.id, avg( elements(foo.names) ), max( indices(foo.names) ) from foo in class eg.Foo group by foo.id]]></programlisting> *************** *** 518,525 **** <para> For databases that support subselects, Hibernate supports subqueries within queries. A subquery must ! be surrounded by parentheses (often by an SQL aggregate function call). eg. </para> ! <programlisting><![CDATA[from cat in class eg.Cat where cat.weight > ( select avg(cat.weight) from cat in class eg.DomesticCat ) --- 532,540 ---- <para> For databases that support subselects, Hibernate supports subqueries within queries. A subquery must ! be surrounded by parentheses (often by an SQL aggregate function call). Even /correlated/ subqueries ! (subqueries that refer to an alias in the outer query) are allowed. </para> ! <programlisting><![CDATA[from fatcat in class eg.Cat where fatcat.weight > ( select avg(cat.weight) from cat in class eg.DomesticCat ) |