-->
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: Transaction and Process Level Caching
PostPosted: Sun Dec 21, 2003 5:16 pm 
Newbie

Joined: Sun Nov 30, 2003 4:46 am
Posts: 17
I wanted to ask which level of caching should be used in Hibernate based web applications?
Caching at transaction level seems to be fine but what if 2 different sessions have loaded 2 different instances of the same object and both sessions try to update them. e.g:
Both sessions load object A with counter property=1
Session 1 increments it by 1 and then updates it in DB
Session 2 also increments it by 1 and then updates it in DB
So the final update will cause the counter property in DB to be set to 2 instead of 3.
Such problems will not arise when Caching of objects is done at the Process level but every object access will have to be synchonised since objects will be shared by all the threads. and this will slow the system down.
So which mechanism is more preferrable and should cause less problems as far as Synchronization and preservation of data Integrity are concerned?

Thanx in advance for suggestions and tips


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 21, 2003 8:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Optimistic locking is used to control such situations. See version or timestamp tags.


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.