Date: 2004-11-16T22:53:39
Editor: DerekLastname <[EMAIL PROTECTED]>
Wiki: Cocoon Wiki
Page: GettingStartedWithCocoonAndHibernate
URL: http://wiki.apache.org/cocoon/GettingStartedWithCocoonAndHibernate
no comment
Change Log:
------------------------------------------------------------------------------
@@ -194,9 +194,9 @@
Now suppose you have five Articles in your database, say A,B,C,D,E. A links to
B and D while B links to C and D links to E. If you use hibebernate to fetch
Article A from the database, it will also fetch ''all other Articles,'' since
you could theoretically navigate to all of them using getter methods, i.e. you
could reference Article E by typing:
-{{{
-Article E = A.getRelatedArticles().get(1).getRelatedArticles().get(0);
-}}}
+
+{{{ Article E = A.getRelatedArticles().get(1).getRelatedArticles().get(0); }}}
+
This can be useful if you know that you are going to use all or most articles
anyway. But in almost every case where you do not need to access your entire
database at once (which is almost every use case I could imagine) it will be
useless and lead to dramatic performance loss.
The solution is called Lazy Collection Initialization. This Hibernate feature
basically leaves all elements in Lists, Maps and other collections
uninitialized until the element is actually accessed via {{get()}} or similar
methods. To turn it on, simply set the attribute "lazy" of the respective
collection to "true":