ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Schall <mike.sch...@gmail.com>
Subject Nested / Multiple Transactions open on same thread?
Date Wed, 04 Jan 2006 17:39:05 GMT
I need the ability to have muliple transactions / connections open to
the same database on the same thread at the same time.

For example I want to:
1) Open a connection and transaction (Session1) to a database
2) Perform multiple inserts to tables in the database
3) Commit and close (Session1)

Easy right.

My problem is that in order to perform the multiple inserts I need to
get / update information in another table.  I have created multiple
DomSqlMapBuilders, configure them with different configuration files,
and store them as separate SqlMapper instances.  So my example needs
to look like

1) Open a connection and transaction (Session1 on SqlMapper1) to a database
2) Open a connection and transaction (Session2 on SqlMapper2) to the
same database
3) Get and Increment Counter (Session2)
4) Commit and close (Session2)
5) Perform insert to table in the database using counter (Session1)
6) Open a connection and transaction (Session2) to the same database
7) Get and Increment Counter (Session2)
8) Commit and close (Session2)
9) Perform insert to table in the database using counter (Session1)
10) ...
11) Commit and close (Session1)

If for any reason I need to rollback (Session1) at step 10, the
actions performed on (Session2) should not be rolled back as they have
been committed.

However when I try and do step 2 SqlMapper2 is already in a
transaction.  It seems like due to the way the session is stored in
TLS, it will only allow for one session to be stored per thread.

Is there a way to get this to work?  I can submit code if that helps.

Thanks for your time.
Mike

Mime
View raw message