-->
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: Reloading data in hibernate
PostPosted: Wed Oct 17, 2007 10:12 am 
Newbie

Joined: Wed Oct 17, 2007 10:04 am
Posts: 1
Hi,
I am new to hibernate. can anyone tell me.
If another application updates database will it reflect in application which is using hibernate. i.e i want to reload the data immediately in hibernate is it possible?

Thanks
Prasad


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 9:20 pm 
Regular
Regular

Joined: Wed Jan 07, 2004 5:16 pm
Posts: 65
Location: CA, USA
If you are using optimistic locking when you update a previously loaded entity you'll find out if someone/something already updated the current row after you last read the row (because the update will fail). This is typically acceptable behavior in web applications because it maintains concurrency by avoiding pessimistic locks on the database.

This however does not address your concern of how do you know if someone else updated a row and how do you retrieve the latest data. You could do this by calling session.refresh() periodically on your entity, but of course you'll pay in the performance hit by doing this depending on how often you call this.

In web-apps it is accepted with optimistic locking that at anytime you may have stale data - this cost is preferable to ensure high concurrency rather than correct data with pessimistic db locks but low concurrency. The approach depends on what you are looking for.


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.