ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Debasish Dutta Roy" <debasish.dutta...@gmail.com>
Subject Re: Rollback Issues
Date Thu, 15 Jun 2006 17:44:22 GMT
OK. What happens is this SP fails. So the idea is a request is created and
inserted, take the request id and call the SP to generate a number. If the
SP fails, the insert of the request should also rollback. Now the SP fails
and REQUEST is not rolled back.

Now, part of the request insert are two calls on DAO1. One to insert in
Request and then the Request Item table. I made a mistake in Request Item
but it did not rollback either. It inserted the REQUEST but not the
REQUEST_ITEM. My mistake with REQUEST_ITEM was a SQLException, invalid
column type. I made an INTEGER as VARCHAR. So that failed the test without
the SP. It should have rolled back the REQUEST also. There is something
wrong...

Can anyone tell me, if I should have a DAOManager for all my business
delegates or should I have one for each. What I mean is I had a Base
Delegate class and put the DAO Manager there. All other delegates, say
RequestDelegate, UtilsDelegate etc. extends BaseDelegate. Then I looked into
the jpetstore example and there each service(delegates) class has a
DAOManager as its member variable. Why? I am wondering the root is somewhere
over there.

Thoughts? Sharing your middle layer design thoughts will help...

On 6/15/06, Jeff Butler <jeffgbutler@gmail.com> wrote:
>
> The plot thickens...
>
> I seem to remember that there is something unusual with Oracle stored
> procedures and transactions.  Sounds to me like the stored procedure call is
> causing a commit somehow.  You could try some other combination of
> statements without a SP call just to check.  I'm not an Oracle person so
> maybe someone else could jump in who's had some experience with stored
> procedures and transactions in Oracle.
>
> Also, what I meant from question 2 was this - what is the actual exception
> you are seeing at runtime that bypasses the commit?  Maybe there is some
> useful information in that exception?
>
> Jeff Butler
>
>
> On 6/15/06, Debasish Dutta Roy <debasish.duttaroy@gmail.com> wrote:
> >
> > OK. Here are the answers
> >
> > 1. First one is an insert & second one is a stored proc call. The first
> > one populates the REQUEST table and the second one gets a number based on
> > the request id.
> > 2. Dao1 and DAO2 catches SQLException and throws DAOException (my
> > exception, not iBATIS DAOException).
> >     This DAOException is caught in the catch block and thrown as a
> > business exception. say RequestFailureException
> > 3. Sampling from my dao.xml
> >
> >
> >     <context>
> >         <transactionManager type="SQLMAP">
> >             <property name="SqlMapConfigResource" value="xml/sql-
> > map-config.xml"/>
> >         </transactionManager>
> >
> >         <!-- DAO declarations -->
> >         <dao interface=" com.novartis.phoenix.db.dao.RequestDAO"
> >             implementation="com.mydao.sqlmap.SqlMapRequestDAOImpl"/>
> >         <dao interface=" com.novartis.phoenix.db.dao.GOSDAO"
> >             implementation=" com.mydao.sqlmap.SqlMapGOSDAOImpl"/>
> >      .......................
> >     </context>
> >
> > Hope this will help.
> >
> >
> > On 6/15/06, Jeff Butler <jeffgbutler@gmail.com > wrote:
> > >
> > >  I think we need a little more information.  I assume that the code
> > > you've prsented is a mocked up example - and everything looks right in your
> > > mock up.
> > >
> > > Questions:
> > >
> > > 1. What is the method secondTask() doing?  Hopefully no transaction
> > > stuff (like another start transaction or a commit).
> > > 2. What Exception is thrown from secondTask()?
> > > 3. By any chance, are DAO1 and DAO2 in different <context> elements in
> > > your dao.xml?  From your mocked up code it doesn't look like they are,
> > > but also doesn't hurt to ask.
> > >
> > > Jeff Butler
> > >
> > >
> > >
> > >
> > > On 6/15/06, Debasish Dutta Roy <debasish.duttaroy@gmail.com > wrote:
> > > >
> > > > offcourse it will be helpful if you could share what you did
> > > > correctly, and if you could find something wrong in my approach. I am
using
> > > > Oracle 9i.
> > > >
> > > >
> > > > On 6/15/06, Tony Qian <daqiqian2@aol.com> wrote:
> > > > >
> > > > >  Yes. It worked for me (MySQL).
> > > > >
> > > > > Tony
> > > > >
> > > > > Debasish Dutta Roy wrote on 6/15/2006, 11:09 AM:
> > > > >
> > > > > Hi All
> > > > > Has anyone successfully tested rollback with DAOManager
> > > > > implementation.
> > > > >
> > > > > I am unable to get it working.
> > > > >
> > > > >
> > > > > I have a business delegate who does like this:
> > > > >
> > > > > DAO1 dao1 = daoManager.getDAO(DAO1.class);
> > > > > DAO2 dao2 = daoManager.getDAO(DAO2.class);
> > > > > try {
> > > > >       daoManager.startTransaction ();
> > > > >       dao1.firstTask();
> > > > >       dao2.secondTask();
> > > > >       daoManager.commitTransaction();
> > > > > } catch (Exception e) {
> > > > >    throw myException;
> > > > > } finally {
> > > > >    daoManager.endTransaction ();
> > > > > }
> > > > >
> > > > >
> > > > > my dao.xml is like this
> > > > >
> > > > >     <context>
> > > > >         <transactionManager type="SQLMAP">
> > > > >             <property name="SqlMapConfigResource" value="xml/sql-
> > > > > map-config.xml "/>
> > > > >         </transactionManager>
> > > > >      ...........
> > > > >      ...........
> > > > >    </context>
> > > > >
> > > > > and the corresponding sql-map-config.xml
> > > > >
> > > > > <sqlMapConfig>
> > > > >
> > > > >     <transactionManager type="JDBC" commitRequired="true">
> > > > >         <dataSource type="JNDI">
> > > > >             <property name="DataSource" value="java:comp/env/jdbc
> > > > > /MyDataSource"/>
> > > > >         </dataSource>
> > > > >     </transactionManager>
> > > > >
> > > > >
> > > >
> > >
> >
>

Mime
View raw message