ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicholoz Koka Kiknadze" <kikna...@gmail.com>
Subject Re: Question on iBatis Implicit Transactions ?
Date Thu, 27 Nov 2008 22:46:17 GMT
2b) Scenario: copy/pasting from manual:

The <transactionManager> element also allows an optional attribute *
commitRequired* that can be *true* or *false*. Normally iBATIS will not
commit transactions unless an insert, update, or delete operation has been
performed. *This is true even if you explicitly call the commitTransaction()
method*. This behavior creates problems in some cases. If you want iBATIS to
always commit transactions, even if no insert, update, or delete operation
has been performed, then set the value of the *commitRequired* attribute to
*true*. Examples of where this attribute is useful include:


   If you call a stored procedures that updates data as well as returning
   rows. In that case you would call the procedure with the queryForList()
   operation – so iBATIS would not normally commit the transaction. But then
   the updates would be rolled back.


So yes, iBatis will rollback.

2a scenario: if you forget to call endTransaction iBatis will do nothing and
sooner or later your connection pool will get exhausted. Copy/pasting again:

Notice how endTransaction() is called regardless of an error. This is an
important step to ensure cleanup. The rule is: if you call
startTransaction() be absolutely certain to call endTransaction() (whether
you commit or not).


1a: Again some little copy/paste ;)

Although using explicit transactions is very highly recommended, there is a
simplified semantic that can be used for simple requirements (generally
read-only). If you do not explicitly demarcate transactions using the
startTransaction(), commitTransaction() and endTransaction() methods, they
will all be called automatically for you whenever you execute a statement
outside of a transactional block


Not sure, but think COMMIT_REQUIRED applies here also, i.e. iBatis will
rollback after any SELECT statement unless COMMIT_REQUIRED=true

Try to use docs from SVN, nowadays they contain far more info than they used
to couple of years ago ;)

On Tue, Nov 25, 2008 at 10:43 PM, mfs <farhan.sarwar@gmail.com> wrote:

> Hello Guys,
> I have got a couple of questions relating to iBatis starting out implicit
> trasactions..Let me add that i am using iBatis "JDBC" TransactionManager.
> Please comment/correct me on the following understanding, given
> 1a) iBatis implicitly starts a transaction if one isn't explicitly started
> ?
> If that is true would iBatis commit the transaction in the end (given we
> never started one mistakenly or otherwise and hence not
> committing/rolling-back) ?
> 2a) Second Scenario. We do start a transaction but don't explicitly do a
> commit in the end. Would iBatis do the commit for you, given no exceptions
> got raised OR it would just rollback the transaction ?
> 2b) Relating to the above scenario, I read somewhere that iBatis would
> rollback the transaction if it is "select" query, what if it is "select for
> update" ?
> Thanks
> Farhan.
> --
> View this message in context:
> http://www.nabble.com/Question-on-iBatis-Implicit-Transactions---tp20694266p20694266.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

View raw message