1 Reply Latest reply on Feb 16, 2011 6:33 PM by Shane Bryzak

    Seam Remoting and lazy-loading

    nraf Newbie

      Using Seam Remoting, I want to retrieve a list of objects (persistent entities?) from the server and display them. At the moment, however, I'm getting a lazy-loading exception.

      I have a Story object, which has a relation to a Author object. When I try to  ethe Story using Seam 2 Remoting, it also attempts to return the Author. When it tries to access the email property of the Author, a lazy-loading exception is thrown.

      While that's one issue in and of itself, I don't really like the idea of having all relations being loaded. For example, when getting a Story, I don't necessarily want the Author object, which may contain a Profile object, which may contain an image to be returned.

      In Seam 3 Remoting, it looks like lazy loading relationships are ignored (with the option to populate). Is there anything similar in Seam 2? If not, how should I approach such a situation?

        • 1. Re: Seam Remoting and lazy-loading
          Shane Bryzak Master

          In Seam 3 you would probably use the Model API to do this.  In Seam 2, I would probably recommend that you do the fetching within the scope of a conversation, meaning that the persistence context 'hangs around' for multiple requests.  You would need to write a conversation-scoped action component that provided separate methods to fetch the stories, authors, etc and call those methods using remoting as required.