-->
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.  [ 9 posts ] 
Author Message
 Post subject: Why assemble and disassemble?
PostPosted: Wed Dec 29, 2004 11:58 am 
Newbie

Joined: Mon Dec 27, 2004 1:42 pm
Posts: 3
I understand that the secondary cache stores objects in a disassembled state, but I don't understand why. Wouldn't it be easier to store the object in its assembled state then return the actual object when it is needed? Or if there are problems with returning the original object, then why not return a deepCopy?

I only ask because I'm working on a project where it would be much better if the secondary cache could return the original reference to an object (like the session-level cache) rather than an assembled duplicate. I know this isn't Hibernate's behavior, but I'm just wondering why.

Peter Dolberg


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 12:34 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Because Hibernate implements transaction-scoped identity and every concept in Hibernate has been designed around this fact.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 29, 2004 5:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
and what would you do when two sessions refer to the same object/collection - which one should win those updates ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 03, 2005 2:46 pm 
Newbie

Joined: Mon Dec 27, 2004 1:42 pm
Posts: 3
I guess what I was looking for is a way to get the same behavior from Hibernate even when I close a session and open a new one. If I try to load the same object twice from the same session then I get back the same object reference each time. If I load one in one session, close the session, then load the same object in another session, then I simply get a duplicate. I was hoping that there was a way to avoid getting a duplicate.

The only way to consistently get back the same object reference is inside a single session, and with a multithreaded web application this means sychronized access to a single session for the whole webapp. This seems like it would be a rather bad bottleneck performance-wise.

As for who wins the update battle, is there no way to prevent objects from getting updated unless I call an explicit session.update()? In that case the session that I call that method on would win.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 03, 2005 6:11 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
session.update is related to detach instance, not UPDATE statement

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 04, 2005 12:55 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
pdolberg wrote:
The only way to consistently get back the same object reference is inside a single session, and with a multithreaded web application this means sychronized access to a single session for the whole webapp. This seems like it would be a rather bad bottleneck performance-wise.


TOPLink does this, and as you have guessed, it results in astonishingly poor performance in a multi-threaded application.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 05, 2005 1:10 am 
Newbie

Joined: Wed Jan 05, 2005 1:01 am
Posts: 1
This is of course a patently false statement. TopLink offers much, much, more flexiblity and options on how to control access, caching and synchronization.

- Don


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 05, 2005 1:33 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Hey Donald, now giving Hibernate support in your free time? :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 6:04 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
Donald Smith wrote:
This is of course a patently false statement. TopLink offers much, much, more flexiblity and options on how to control access, caching and synchronization.

- Don


Well, I can't seem to get any of the alleged flexibility to work. Invalidating cached entries doesn't work reliably (and cannot work in all cases because the actual mapped objects are cached, misbehaving code might have references to the objects).

Also, there are some bugs in the version that I'm using that cause it to return incomplete result sets due to incorrect useage of weak references. I'm not sure if that's a cacheing issue.


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