Added documentation for scalar sql queries
git-svn-id: https://svn.jboss.org/repos/hibernate/trunk/Hibernate3/doc@5281 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
0af8f34752
commit
e36b59f776
|
@ -84,7 +84,7 @@ List loggedCats = sess.createSQLQuery(sql, "cat", Cat.class)
|
|||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querysql-namedqueries">
|
||||
<sect1 id="querysql-namedqueries" revision="1">
|
||||
<title>Named SQL queries</title>
|
||||
|
||||
<para>
|
||||
|
@ -104,6 +104,24 @@ List loggedCats = sess.createSQLQuery(sql, "cat", Cat.class)
|
|||
FROM PERSON {person} WHERE {person}.NAME LIKE 'Hiber%'
|
||||
</sql-query>]]></programlisting>
|
||||
|
||||
<para>
|
||||
Using named SQL queries, you may also query for scalar values. To do this, use the type attribute
|
||||
of the return element and specify a Hibernate type there:
|
||||
</para>
|
||||
|
||||
<programlisting><![CDATA[<sql-query name="mySqlQuery">
|
||||
<return alias="name" type="string"/>
|
||||
<return alias="age" type="long"/>
|
||||
SELECT p.NAME AS {name},
|
||||
p.AGE AS {age},
|
||||
FROM PERSON p WHERE p.NAME LIKE 'Hiber%'
|
||||
</sql-query>]]></programlisting>
|
||||
|
||||
<para>
|
||||
You can also use custom types and typedefs you defined in the type attribute (remember that
|
||||
the mapping file containing the typedefs has to be added earlier to the configuration).
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<sect1 id="querysql-cud">
|
||||
|
|
Loading…
Reference in New Issue