I don't know if you already know this and there's a reason why you aren't doing it this way or not, but, in HQL, you can use "fetch" to tell it to do an immediate load of collections even if the mapping files specify them as lazy.

Jon

----- Original Message ----- From: "Enrique Medina" <[EMAIL PROTECTED]>
To: "MyFaces Discussion" <[email protected]>
Sent: Saturday, June 18, 2005 1:16 PM
Subject: DataScroller & Lazy loading collections


Hi,

Maybe this is not the most adequate forum to post this question, but I
know many of you are using MyFaces together with Spring & Hibernate,
so it would be great it you give me some comments.

The problem I have comes with Lazy collections in my objects. Assuming
you know how to use Hibernate & Spring, the problem comes when I try
to paginate my DataTable using the DataScroller, because the
OpenSessionInViewFilter pattern establishes the session Hibernate in
the initial query (the one that shows the first page of the
DataTable). So, when the following page is needed, as MyFaces executes
a new request, the session binded by the OpenSessionInViewFilter for
this new request, is not obviously the same as the session previously
established at the first request.

Finally, I always get a Lazy initialization exception from Hibernate,
as you surely have imagined...

So my question is very simple:

How do you manage objects with lazy collections being shown in
different request with respect to the OpenSessionInViewFilter pattern?

Thanks in advance. I'm looking forward to hearing your comments.

Enrique Medina.


Reply via email to