ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brandon Goodin" <brandon.goo...@gmail.com>
Subject Re: Help with understanding transaction behavior with multiple threads
Date Sat, 10 Jun 2006 02:28:23 GMT
Maybe if you provided us with more context around your thread creation
and how it dovetails in with ibatis. To be honest we can't offer you
advice on something we know nothing about.

Brandon

On 6/9/06, Eric T. Blue <ericblue76@gmail.com> wrote:
> No takers on this one?
>
>
>
> On 6/5/06, Eric T. Blue <ericblue76@gmail.com> wrote:
> >
> > Hi,
> >
> > I want to find out the easiest possible way to start a transaction, create
> a thread that performs DAO inserts, and still have the newly created thread
> honor the start and end transaction from the launching application.
> >
> > I'm working on a project where I'm using iBatis DAO with SQLMAP as my
> transaction manager.  Up until this point transactions and rollbacks work
> fine.
> >
> > daoManager.startTransaction();
> >
> > try {
> >     service.createObject (a);
> >
> >     daoManager.commitTransaction();
> >
> > } catch (ServiceException e) {
> >     // Handle exception
> > } finally {
> >
> >     daoManager.endTransaction();
> > }
> >
> > I now have a situation where instead of calling service.createObject()
> directly I'm creating an encapsulated unit of work and running with a new
> thread.  What I've discovered is that whenever an exception is thrown, the
> create Object exists in the database, although commitTransaction has never
> been called.  After browsing through the mailing list, and eventually the
> code, I discovered that the dao manager (DaoContext) is using ThreadLocal to
> keep track of transaction and state.  Given this fact, is it even possible
> to solve my problem without having to change the underlying code or right
> some sort of wrapper class.
> >
> > What I'm a little confused about is that default autocommit is set to
> false.  If the launched thread performs the INSERT, even though it is
> unaware that start transaction and end transaction are happening, why is the
> record being committed?  Any help would be appreciated.
> >
>
>

Mime
View raw message