-->
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.  [ 5 posts ] 
Author Message
 Post subject: Why hibernate cache does not store object instances?
PostPosted: Thu Jan 05, 2006 7:52 pm 
Beginner
Beginner

Joined: Mon Sep 06, 2004 9:36 am
Posts: 35
I was reading an article about Hibernate Caching and one thing jumps to my notice:

"One thing you should know is that the Hibernate cache does not store object instances. Instead, it stores objects in their "dehydrated" form (to use Hibernate terminology), that is, as a set of property values."

My question is why Hibernate cache does not store object instances. Are there any drawbacks with storing obejct instances?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 06, 2006 11:04 am 
Beginner
Beginner

Joined: Mon Sep 06, 2004 9:36 am
Posts: 35
Anyone please?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 06, 2006 11:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
#1: if we returned the same object instance to multiple concurrent sessions they would no longer be isolated and you would get hard to find consistency issues

#2: Since we can't return the same object instances to multiple concurrent sessions why should we waste cpu cycles on creating objects we don't need ?

#3 Read Hibernate In Action which explains this (and much more)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 06, 2006 11:51 am 
Beginner
Beginner

Joined: Mon Sep 06, 2004 9:36 am
Posts: 35
Quote:
#1: if we returned the same object instance to multiple concurrent sessions they would no longer be isolated and you would get hard to find consistency issues


for a read-only cache would not it make more sense to have the same object instance to mulitple concurrent sessions? why would i want isolation in this case?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 06, 2006 11:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
For consistency and to shield you from users which might have invoked operations on the cached object that mutates it...

If you know you can handle that then implement Interceptor.getEntity() to keep a cache of precreated objects.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.