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.
- Help with understanding transaction behavior with multiple ... Eric T. Blue
- Re: Help with understanding transaction behavior with ... Eric T. Blue
- Re: Help with understanding transaction behavior w... Brandon Goodin
- Re: Help with understanding transaction behavior with ... Clinton Begin
- Re: Help with understanding transaction behavior w... Brandon Goodin
- Re: Help with understanding transaction behavi... Eric T. Blue
