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
======
|
|