Hibernate version: 3.0.5 (or any)
Name and version of the database you are using: Postgres 8.1
This isn't a bug or problem as much as a general question. I've been slow to ask this because I'm sure the answer is out there, yet I've spent a lot of time and haven't really gotten the answer that I want. So here I am, bugging you fine people.
What I want to find out is the details of serialization with hibernate and proxy associations. Here's what I'm doing.
My app is JSF, myfaces implementation, with hibernate as the database backend. I use an "Open Session in View" type pattern. Essentially I commit the transaction in a filter at the end of the view rendering. Otherwise, all data access happens through "natural" pojo calls inside of the single transaction.
In JSF, datatables require the data set being viewed to persist itself in some way. The standard datatable seems to best hold its data in the session, which I've found problematic for any number of reasons. However, the myfaces extension allows you to stuff the data into the request's view storage by way of serialization. This has any number of beneficial consequences (performance arguably not one of them, but this isn't a heavy traffic app). My major concern has to do with how hibernate handles serializtion.
Lets say I have a java.util.List of objects. This list has been returned from a hibernate query. As the JSF table looped through the objects, it made calls to associated proxy objects. This should on its own "flush out" the lazy loaded object model. At this point on each object in the list, lets say 2 lazy proxied objects have been loaded, but lets say there's another proxy that points back to some larger structure, and potentially the rest of the object grazy. This proxy HAS NOT been called during the view rendering.
1) In an environment without a second level cache, what happens when this list is serialized?
a) Will the two loaded proxies be serialized? I'm 99.9% sure that they will, from coding experience.
b) Will the third proxy remain un-loaded? This is what I'm hoping will happen, as I'd like to avoid dumping the whole object graph.
2) If there is a second level cache, what happens? Let's say that another page had loaded one of our test objects, and had called the third proxy for its own purposes. In this page, that loaded the object from hibernate and did not call the third object, will the third object be loaded, or would it still be an unloaded proxy?
This is a bit abstract and could probably use a more concrete example. If anybody was able to follow that and has an answer, please let me know. Your response will be greatly appreciated.
|