-->
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: How to implement efficient concurrent update in cluster?
PostPosted: Mon Mar 29, 2004 5:20 pm 
Newbie

Joined: Mon Mar 29, 2004 4:52 pm
Posts: 2
Hi,

I'm looking for the efficient solution of following problem using hibernate:

Scenario:
- Two node cluster
- Each node concurrently adds some value to "price" in the same "account"

SQL Solution:
state before: price=1 for account id=4
NODE1: stm1.execute("update account set price=price+3 where id=4")
NODE2: stm2.execute("update account set price=price+8 where id=4")
state after: price=12 for account id=4

Hibernate Solution:
state before: price=1 for account id=4
NODE1: trans1.start()
NODE1: sess1.load(account1, 4)
NODE1: account1.price=account1.price+3
NODE1: trans1.commit()

NODE1: trans2.start()
NODE1: sess2.load(account2, 4)
NODE1: account2.price=account2.price+8
NODE1: trans2.commit()
state after: price=12 for account id=4

I suppose Hibernate solution will use at minimum 4 SQL queries in transaction, but SQL solution needs only two simple updates.

Is there better solution for this scenario?
I've considered using JBossCache but, i'm afraid that cluster communication overhead could be bigger then Hibernate overhead.

Thang you for any ideas
David


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 31, 2004 9:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Did you looked at optimistic locking (version) ?

_________________
Emmanuel


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.