-->
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.  [ 4 posts ] 
Author Message
 Post subject: find in multiuser environment
PostPosted: Mon Sep 08, 2003 5:19 am 
Regular
Regular

Joined: Mon Sep 08, 2003 4:53 am
Posts: 70
Location: Germany
I'm using hibernate in a multiuser environment. This means, many users are able to update an object on the database at the same time using different (hibernate) sessions.

My problem is, that an object o, that was once loaded from the db, is cached and not reloaded from db, until I force this by an explicit session.reload(o). This means, if o belongs to a result of a session.find() it's not reloaded, even if the database tupel, that belongs to o, was updated and committed by another session. So the session, that uses the find(), doesn't get the actual persistent state of o.

What I need, is a mechanism, that forces the find() command, to reload object o, when the database tupel has been changed between session.load() and session.find().

Any idea? Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 08, 2003 5:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
If you are not doing evil things like using a long-running session, all that this behaviour does is helps enforce transaction isolation.


If you are using long-running sessions then STOP :)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 08, 2003 8:28 am 
Regular
Regular

Joined: Mon Sep 08, 2003 4:53 am
Posts: 70
Location: Germany
Thanks for the quick response.

But I'm not sure, I understand, how transaction isolation would help me in this case? Could you give me more details?

By the way, I found session.clear() in hibernate 2.1. If I use this before the session.find() statement, it solves my problem. Do I get any disadvantages by using session.clear() before every session.find() statement?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 08, 2003 10:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Your clearing the session cache hence it has to hit the database to get the objects which sounds like your using long running sessions to me. Disadvantage is a drop in potential performance due to forced cache flushes. In reality this has a bit of a smell and I would reconsider the architecture you are using.


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