docd new HQL features
git-svn-id: https://svn.jboss.org/repos/hibernate/trunk/Hibernate3/doc@6346 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
ef9db9a5d7
commit
0131d8337d
|
@ -196,14 +196,23 @@ select cust.name.firstName from Customer as cust]]></programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
Queries may return multiple objects and/or properties as an array of type
|
Queries may return multiple objects and/or properties as an array of type
|
||||||
<literal>Object[]</literal>
|
<literal>Object[]</literal>,
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<programlisting><![CDATA[select mother, offspr, mate.name
|
<programlisting><![CDATA[select mother, offspr, mate.name
|
||||||
from DomesticCat as mother
|
from DomesticCat as mother
|
||||||
inner join mother.mate as mate
|
inner join mother.mate as mate
|
||||||
left outer join mother.kittens as offspr]]></programlisting>
|
left outer join mother.kittens as offspr]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
or as a <literal>List</literal>,
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting><![CDATA[select new list(mother, offspr, mate.name)
|
||||||
|
from DomesticCat as mother
|
||||||
|
inner join mother.mate as mate
|
||||||
|
left outer join mother.kittens as offspr]]></programlisting>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
or as an actual typesafe Java object
|
or as an actual typesafe Java object
|
||||||
</para>
|
</para>
|
||||||
|
@ -216,6 +225,24 @@ from DomesticCat as mother
|
||||||
<para>
|
<para>
|
||||||
assuming that the class <literal>Family</literal> has an appropriate constructor.
|
assuming that the class <literal>Family</literal> has an appropriate constructor.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
You may assign aliases to selected expressions using <literal>as</literal>:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting><![CDATA[select max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n
|
||||||
|
from Cat cat]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This is most useful when used together with <literal>select new map</literal>:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting><![CDATA[select new map( max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n )
|
||||||
|
from Cat cat]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This query returns a <literal>Map</literal> from aliases to selected values.
|
||||||
|
</para>
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
@ -768,6 +795,15 @@ where cat.name not in (
|
||||||
select name.nickName from Name as name
|
select name.nickName from Name as name
|
||||||
)]]></programlisting>
|
)]]></programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
For subqueries with more than one expression in the select list, you can use a "row constructor".
|
||||||
|
<para>
|
||||||
|
|
||||||
|
<programlisting><![CDATA[from Cat as cat
|
||||||
|
where not ( cat.name, cat.color ) in (
|
||||||
|
select cat.name, cat.color from DomesticCat cat
|
||||||
|
)]]></programlisting>
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
<sect1 id="queryhql-examples">
|
<sect1 id="queryhql-examples">
|
||||||
|
|
Loading…
Reference in New Issue