You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by se...@nexgo.de on 2003/12/30 01:27:13 UTC
how can i do multiple operations in one transaction?
Hi,
I am using the PersistenceBroker (OJB 1.0 rc5) and have some problems to store 2 objects within a single transaction. The problem is, that I want to have the whole transaction comitted if and only if a calculation between these two store operations has been successfull, otherwise the first store operation will be rolled back. Consider the following code snippet:
try{
pm = PersistenceBrokerFactory.defaultPersistenceBroker();
pm.beginTransaction();
pm.store(object1);
}
catch ...
followed by some calculations then retrieve the first object to get the id (which was set by OJB via autoincrement) ...
try{
pm.getObjectId(object1);
}
catch ...
follwed by another operation and if succeeded then store object2 and finish the transaction:
try{
pm.store(object2);
pm.comitTransaction();
pm.close();
}
catch...
I always get a TransactionNotInProgressException. How can I solve this problem?
thx,
Dirk
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org