Update of /cvsroot/hibernate/Hibernate/doc
In directory sc8-pr-cvs1:/tmp/cvs-serv26528/doc
Modified Files:
faq.aft faq.aft-TOC faq.html
Log Message:
new FAQ entries
Index: faq.aft
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/doc/faq.aft,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** faq.aft 26 Nov 2002 10:25:24 -0000 1.30
--- faq.aft 27 Nov 2002 15:00:14 -0000 1.31
***************
*** 156,159 ****
--- 156,175 ----
( (Integer) s.createFilter( collection, "select count(*)" ).iterate().next() ).intValue()
+ *** How can I order by the size of a collection?
+
+ For a one-to-many or many-to-many association:
+
+ select user from user in class eg.User, msg in user.messages.elements group by user order by count(msg)
+
+ *** How can I place a condition upon a collection size?
+
+ If your database supports subselects:
+
+ from user in class eg.User where user.messages.size >= 1
+
+ If not, and in the case of a one-to-many or many-to-many association:
+
+ select user from user in class eg.User, msg in user.messages.elements group by user having count(msg) >= 1
+
*** How can I sort / order collection elements?
Index: faq.aft-TOC
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/doc/faq.aft-TOC,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** faq.aft-TOC 14 Nov 2002 12:57:37 -0000 1.20
--- faq.aft-TOC 27 Nov 2002 15:00:16 -0000 1.21
***************
*** 23,26 ****
--- 23,28 ----
* {-How can I count the number of query results without actually returning them?@How can I count the number of query results without actually returning them?-}
* {-How can I find the size of a collection without initializing it?@How can I find the size of a collection without initializing it?-}
+ * {-How can I order by the size of a collection?@How can I order by the size of a collection?-}
+ * {-How can I place a condition upon a collection size?@How can I place a condition upon a collection size?-}
* {-How can I sort / order collection elements?@How can I sort / order collection elements?-}
* {-Are collections pageable?@Are collections pageable?-}
Index: faq.html
===================================================================
RCS file: /cvsroot/hibernate/Hibernate/doc/faq.html,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** faq.html 26 Nov 2002 10:25:24 -0000 1.43
--- faq.html 27 Nov 2002 15:00:17 -0000 1.44
***************
*** 48,51 ****
--- 48,53 ----
<li> <a href="#How can I count the number of query results without actually returning them?">How can I count the number of query results without actually returning them?</a></li>
<li> <a href="#How can I find the size of a collection without initializing it?">How can I find the size of a collection without initializing it?</a></li>
+ <li> <a href="#How can I order by the size of a collection?">How can I order by the size of a collection?</a></li>
+ <li> <a href="#How can I place a condition upon a collection size?">How can I place a condition upon a collection size?</a></li>
<li> <a href="#How can I sort / order collection elements?">How can I sort / order collection elements?</a></li>
<li> <a href="#Are collections pageable?">Are collections pageable?</a></li>
***************
*** 281,284 ****
--- 283,308 ----
<pre>
( (Integer) s.createFilter( collection, "select count(*)" ).iterate().next() ).intValue()
+ </pre>
+ <!--End Section 3-->
+ <h4><a name="How can I order by the size of a collection?">How can I order by the size of a collection?</a></h4>
+ <p class="Body">
+ For a one-to-many or many-to-many association:
+ </p>
+ <pre>
+ select user from user in class eg.User, msg in user.messages.elements group by user order by count(msg)
+ </pre>
+ <!--End Section 3-->
+ <h4><a name="How can I place a condition upon a collection size?">How can I place a condition upon a collection size?</a></h4>
+ <p class="Body">
+ If your database supports subselects:
+ </p>
+ <pre>
+ from user in class eg.User where user.messages.size >= 1
+ </pre>
+ <p class="Body">
+ If not, and in the case of a one-to-many or many-to-many association:
+ </p>
+ <pre>
+ select user from user in class eg.User, msg in user.messages.elements group by user having count(msg) >= 1
</pre>
<!--End Section 3-->
|