-->
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.  [ 3 posts ] 
Author Message
 Post subject: Understanding transaction management
PostPosted: Mon Dec 12, 2005 9:19 am 
Newbie

Joined: Mon Dec 12, 2005 8:57 am
Posts: 13
Hi all,

I've read the documentation (thoroughly) but I'm unsure about my understanding of the transaction management.

I would like to inform the user if another user is currently editing a register (it's a contact center application) avoiding the "last commit wins" approach. I would like Hibernate to handle as much work as possible (no app version checking) throwing an exception when the record the user intends to update is in an inconsistent state.

It's a J2EE managed environment with DAOs (singletons) handling DB operations. Each DAO has a Session variable. Each DAO handles all the operations for a specific type of object.

Would this code work for me? (foo is an object obtained before using this DAO and that has been modified during per user actions)

public class AccountDAO... {
...
function save(Account foo) throws Exception {
session.reconnect();
Transaction t = session.beginTransaction();
save(foo);
t.commit();
session.disconnect();
}
}

Would this throw an exception if another user changed foo data since first load? What should I change to support concurrency here?

Thank you in advance.

XMaNIaC
======


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 9:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://hibernate.org/42.html
http://hibernate.org/43.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 12, 2005 12:45 pm 
Newbie

Joined: Mon Dec 12, 2005 8:57 am
Posts: 13
Yeah, I haven't read those yet...


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