Hi Andrus,
I tried the following method you suggested and it works great in cayenne
managed standalone application but it behaves different within stateless
session EJB in JBOSS with cayenne managed transaction and using external
transaction.
with cayenne managed transaction in EJB, it does not commit changes done
by storedProcA when storedProcB fails but it does commit those changes
when I call the same ejb method second time.
with container managed transaction in EJB, it does commit the changes done
by storedProcA even when storedProcB fails.
Please let me know If I am missing anything.
Attached is the code I used for testing.
- Bhagwanji
-----Original Message-----
From: Andrus Adamchik [mailto:andru..bjectstyle.org]
Sent: Monday, February 28, 2005 10:53 AM
To: cayenne-use..bjectstyle.org
Subject: Re: Stored Procedure Query and Transactions
Forget Spring ... It'll work of course, but I am overcomplicating the
issue and really need more coffee. You can do a one-off transaction, while
keeping clean implicit transaction handling everywhere else. And can't be
any simpler than that:
List queries = new ArrayList();
queries.add(query1);
queries.add(query2);
// this will run both queries in the same transaciton
// doing a rollback on failure
dataContext.performQueries(queries, new QueryResult());
Andrus
>> Hi,
>>
>> I have some existing oracle stored procedures with business logic in
>> our DB. I have created cayenne model for those procedures. I am
>> calling storedProceA and then storedProcB. I have a requirement where
>> I need to rollback all the work done by storeProcA if storeProcB
>> fails. Is it possible to rollback stored procedure call using cayenne
>> ? Please let me know if there is a way to tie both the storeProc calls
>> in a single transaction and either commit or rollback in a single
>> transaction.
>>
>> - Bhagwanji
>
>
> Hi,
>
> You will need to run Cayenne with "external transactions" flag checked,
> and provide some external transaction mechanism. The easiest (but not
> the only) way to implement such externa transactions is to use Spring
> framework (www.springframework.org). Cayenne-Spring integration code and
> examples can be downloaded from here -
> http://objectstyle.org/cayenne/lists/cayenne-user/2004/12/0153.html (it
> is submitted to Spring already and is scheduled to become a part of
> their official distro in 1.3 release).
>
> And of course make sure that your procedures do not commit internally...
>
> Andrus
This archive was generated by hypermail 2.0.0 : Tue Mar 01 2005 - 10:40:21 EST