6 Replies Latest reply on Feb 17, 2007 12:36 PM by seto

    Needing help for the lazy initialize

    seto

      In hibernate, we can use below code to limit the collection's size.

      s.createFilter( lazyCollection, "").setFirstResult(0).setMaxResults(10).list();
      


      How can I do such thing in JBoss Seam, or in the other words, EJB3.

      Maybe I posted in the wrong forum, but I'm using Seam, so I post it here.

        • 1. Re: Needing help for the lazy initialize
          seto

          I just have a three level relationship.
          Category 1...* Position 1...* Article
          My home page is listing the categories with the position below and articles below. I want to limit the size initilize size of the articles. I'm using the sublist to get the recent 10 articles. But it can't limit the initilize and the performance is so bad.

          • 2. Re: Needing help for the lazy initialize
            seto

            Can someone help me? I learn from the blog use the sublist, I'm in trouble with rows up to 1000. It cost seconds to finish the loading.

            • 3. Re: Needing help for the lazy initialize
              seto

              for example

              <ul>
              <ui:repeat value="#{catgories}" var="catgory">
               <li>#{category.name}</li>
               <ul>
               <ui:repeat value="#{catgory.positions}" var="position">
               <li>#{position.name}</li>
               <ul>
               <ui:repeat value="#{position.articles}" var="article">
               <li>#{article}</li>
               </ui:repeat>
               </ul>
               </ui:repeat>
               </ul>
              <ui:repeat>
              </ul>
              


              Refering to the blog example, I used the #{position.recentArticles} instead.
              public List getRecentArticles(){
               return articles.sublist(0, 10);//just a example so ignore the length problem
              }
              

              But it also initilized the other articles. And it cause the performance leak. And I want to limit the initialization of the articles. I want it just initilize the recent 10 articles. How can I do that?

              • 4. Re: Needing help for the lazy initialize
                lawrieg

                Take a look at section 8.4 'Using the JPA "delegate"' and 8.5 'Using Hibernate filters' in the Seam reference documentation - it seems like this might be what you are looking for.

                Hope this helps,

                Lawrie

                • 5. Re: Needing help for the lazy initialize
                  gavin.king

                  There's no support for this in EJB3. Just use an ordinary query.

                  • 6. Re: Needing help for the lazy initialize
                    seto

                    lawrieg, thanks. Youre advice helps. I just use the session to implement the part initialize of the collection. Thank you.
                    Also thanks to gavin.