-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Serialization and proxies
PostPosted: Wed Sep 20, 2006 2:32 pm 
Newbie

Joined: Wed Sep 20, 2006 2:10 pm
Posts: 2
Location: New York
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 6:09 pm 
Newbie

Joined: Wed Sep 20, 2006 2:10 pm
Posts: 2
Location: New York
Ok. Did a little personal testing. Serializing a proxied object will serialize the proxy, but not pull down the reachable object graph. Also, attempting to access the proxy after de-serializing will throw an exception (even if still in the same transaction).

This is good.

Now, I've never used the second level cache with a hibernate application. Any input with regards to caching and my original post?

Thanks in advance,
-Kevin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.