ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: SqlSession.close() without committing
Date Tue, 06 Apr 2010 03:34:33 GMT
Yes, iBATIS will rollback the connection if it deems it necessary.  The only
time you might need to call rollback explicitly is if you have a "select"
that actually updates data in the database.  Such is sometimes the case with
stored procedures.

Clinton

2010/4/5 Fran├žois Schiettecatte <fschiettecatte@gmail.com>

> If you start a transaction or don't have auto-commit on, then the
> transaction will be rolled back. At least that is what I am seeing which
> makes sense to me.
>
> F.
>
> On Apr 5, 2010, at 12:38 PM, cowwoc wrote:
>
> > Hi,
> >
> >    What happens if I close() a SqlSession without committing? Does iBatis
> guarantee that the transaction will roll back? I ask because I want to use
> the following pattern:
> >
> > SqlSession session = factory.openSession();
> > try
> > {
> >  // do work
> >  session.commit();
> > }
> > finally
> > {
> >  session.close();
> > }
> >
> >    If no exception is thrown, the session gets committed. Otherwise, it
> is rolled back without having to catch exceptions and explicitly roll back.
> >
> > Thanks,
> > Gili
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> > For additional commands, e-mail: user-java-help@ibatis.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Mime
View raw message