Enrique Medina wrote:
Hi Werner,

What I would try to achieve with the callback mechanism would be
simply to get the reference to the current object, and reattach it to
the current session. Please take into account that I'm currently using
the OpenSessionInViewFilter pattern from Spring, so the session would
be automatically opened and closed in a transparent way.

Ok I am not familiar with that one, I have to look that up
(I have to admit I use Spring also, but for other stuff)
if this one works well then you are set, but it seems rather that it
does not really do the stuff you want to achieve.


So the only hit in performance would be the call to
Hibernate.lock(object, LockMode.NONE) for each object in each row in
the DataModel. If there are many of them, maybe it's worth the effort
instead of having to preload everything into memory, without lazy
loading it.

well as I said I have to read that Spring pattern up, but the datamodel is pure read only, so no lock is required. I will try to explain the flow from the datatable control to the datamodel... First the datamodel is initialized, then a request is started for the number of rows, then row by row the model is asked to deliver the data
and the row counter is increased.
Once the rendering is finished the rows basically are not requested anymore but nothing is sent to the datamodel to free the resources (shale fixes that).

Now to your lazy loading, for some strange kind of reason you seem to loose the session along the way. Since you do pagination, and that is the huge leak I see in my understanding of things, since I do not know exactly what the OpenSessionInViewFilter does, is that the session probably is not reopened or closed to early. (It is probably closed after the first loading and never triggered again or closed to early)
Thus you run into the lazy loading problem.
There seems to be a problem between the way the datamodel is handled internally and the OpensessionInViewFilter is triggered.

My guess is that the pagination basically has to store some data in the session or server and thus, the pagination basically Interferes with the OpenSessionInViewFilter.


What do you think? I've been looking at ListDataModel implementation
of the DataModel interface, and it could be easily extended with a
callback mechanism every time the getRowData is invoked...

exactly that is the way to do it, as I said, the shale datamodel approach might be the best to solve your problem, since you have full control over the session/transaction scope that way. (I have something with a prefetch caching window sort of working-without shale, but I am not happy with that, because that one also has the lazy loading problem, you describe)

Reply via email to