Hi Jonathan, 

Yes, I know that issue, but it does not fit into my scenario because:

a) I really want to do lazy loading
b) I'm currently using the Criteria API, as I have a dynamic set of
criterion in my form, where the user can enter either all the criteria
or just something or even none, so the SQL must be dynamically
created. The Criteria by Example is perfect for this, while using HQL
would lead to annoying if...then... clauses

So in resume, I could have made the lazy collections to be prefecthed
also using the Criteria API, but that's not the behaviour I was
requiring ;-)

2005/6/20, Jonathan Eric Miller <[EMAIL PROTECTED]>:
> 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