Hello all,
I tested my own solution suggested below, but it still did not work. The
class that I got for connection was :
[EMAIL PROTECTED]
wrapped [EMAIL PROTECTED]
]
Why wouldn't straight commit() and rollback() not work on a Connection?
Any help is greatly appreciated. Thank you.
Regards,
-Vamsi
--- Vamsi Atluri <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I am having problem with getting my transactions rolled back. I have
> read
> the documentation a bit about OTM but I am not clear about what I should
> do in my situation.
>
> I am using OJB1.0.1 for DB2 and running on WAS 5.0 (currently testing on
> WSAD 5.1.2). My data save code looks something like this:
>
> PersistenceBroker broker =
> PersistenceBrokerFactory.defaultPersistenceBroker();
>
> try {
> broker.beginTransaction();
>
> broker.store(objA); //step 1
> broker.store(objB); //step 2
> broker.store(objC); //step 3
> broker.deleteByQuery(someQuery); //step 4
> broker.store(objD); //step 5
>
> broker.commitTransaction();
> } catch(PersistenceBrokerException pbe) {
> if(null != broker) {
> broker.abortTransaction();
> }
> } catch(Exception e) {
> if(null != broker) {
> broker.abortTransaction();
> }
> } finally {
> if(null != broker) {
> broker.close();
> }
> }
>
> It so happens that if there is any Exception during any of the steps,
> the
> previous steps are not being rolled back. Is it possible that I can get
> the ConnectionManager from the broker and use it for managing my
> transactions? The document says that OJB provides only DB level
> transactions but not object level transactions. What does that this
> exactly mean? Do I "have" to implement OTM (which would be a huge
> undertaking given the amount of tables we store)? Or can I do something
> like this:
>
> PersistenceBroker broker =
> PersistenceBrokerFactory.defaultPersistenceBroker();
> java.sql.Connection conn = null;
>
> try {
> ConnectionManagerIF connectionManager =
> broker.serviceConnectionManager();
> conn = connectionManager.getConnection();
> conn.setAutoCommit(false);
>
> broker.store(objA); //step 1
> broker.store(objB); //step 2
> broker.store(objC); //step 3
> broker.deleteByQuery(someQuery); //step 4
> broker.store(objD); //step 5
>
> conn.commit();
> } catch(PersistenceBrokerException pbe) {
> if(null != conn) {
> conn.rollback();
> }
> } catch(Exception e) {
> if(null != conn) {
> conn.rollback();
> }
> } finally {
> if(null != broker) {
> broker.close();
> }
> }
>
> Any help is greatly appreciated in this matter. Thank you.
>
> Regards,
> -Vamsi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]