1 2 Previous Next 17 Replies Latest reply on Sep 20, 2012 6:38 PM by fastroller Go to original post
      • 15. Re: Why @ViewScope and Seam Managed Persistence Context doesn't work?
        fastroller

        That issue is one I raise quite some time ago. I've since redesigned much of my application so that it does not require an extended persistence context. I would suggest you do the same. If you're using an extended persistence context to avoid lazy initialisation errors they perhaps you need to rethink your design. The solution proposed in the above post requires the EntityManager to be serialised with the view state. Does that really sound like a good idea?

        • 16. Re: Why @ViewScope and Seam Managed Persistence Context doesn't work?
          zeeman

          Andrew,

           

          what exactly did you change in your design? All request scoped EM? You merge detached entities? That's cumbersome to do in each page. There got to be a more elegant way than this.

          • 17. Re: Why @ViewScope and Seam Managed Persistence Context doesn't work?
            fastroller

            In general all my pages are either Request scoped (usually search pages) or ViewScoped (data entry).

             

            I designed my model to use LAZY fetch type, but on the view scoped beans I retrieved the entity using fetch join on the attributes that are going to be displayed on the page. This is more efficient than having the page rendering perform lazy loading. In some cases where I don't want to retrieve the lazy attributes I would re-attach the entity to the entity manager (merge). This was generally required with ajax requests for non-rendered data:

             

            On a rich collapsible panel that is ajax rendered:

             

            <rich:collapsiblePanel switchType="ajax" header="Subsidiaries" expanded="false" toggleListener="#{companyHome.attachInstance}" ajaxSingle="true" execute="@form">
            

             

            In many cases for business logic to execute on the model it required that large portions of the entity graph be retrieved in advance. I still like to keep all collections lazy loaded so that search pages and other queries are not burneded by fetching unnecessary attributes.

            1 2 Previous Next