You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by J S <sh...@yahoo.ca> on 2010/03/08 17:40:10 UTC

SqlSession question

Please exercise some patience if what I am about to ask sounds dumb.  I'm still new to Ibatis; so far it has been a very pleasant experience.

I get the impression that the SqlSession class bundles the functionality of both, transactions and a persistence context.  This mixture is still unclear to me, and I would like to understand more about the semantics behind the SqlSession class.  More specifically, I'd like to understand the relation/side effects between transactions, jdbc connections and the following methods:

SqlSession.clearCache()
SqlSession.commit()
SqlSession.rollback()
SqlSession.close()

Through some brute force experimentation/debugging, I can see that commit() and rollback() hold on to a borrowed connection, while close() returns the connection to the pool.  What's the rationale behind this logic?

Feel free to point me to any docs that may answer some of these.

Thanks.

J




      __________________________________________________________________
The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Yahoo!  Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/

Re: SqlSession question

Posted by Clinton Begin <cl...@gmail.com>.
The only rationale there is to allow for you to commit more than once within
a session scope.  In previous versions of iBATIS this was possible, but was
messy because Session, Transaction and Batches were all managed separately.
 Because we've now merged all three into this one concept, we didn't want to
lose the ability to commit multiple times within a session.

Of course, I highly recommend committing only once and using broadly scoped
transactions as possible.  But that recommendation has little to do with
iBATIS specifically.  :-)

Cheers,
Clinton

On Mon, Mar 8, 2010 at 9:40 AM, J S <sh...@yahoo.ca> wrote:

> Please exercise some patience if what I am about to ask sounds dumb.  I'm
> still new to Ibatis; so far it has been a very pleasant experience.
>
> I get the impression that the SqlSession class bundles the functionality of
> both, transactions and a persistence context.  This mixture is still unclear
> to me, and I would like to understand more about the semantics behind the
> SqlSession class.  More specifically, I'd like to understand the
> relation/side effects between transactions, jdbc connections and the
> following methods:
>
> SqlSession.clearCache()
> SqlSession.commit()
> SqlSession.rollback()
> SqlSession.close()
>
> Through some brute force experimentation/debugging, I can see that commit()
> and rollback() hold on to a borrowed connection, while close() returns the
> connection to the pool.  What's the rationale behind this logic?
>
> Feel free to point me to any docs that may answer some of these.
>
> Thanks.
>
> J
>
>
> ------------------------------
> Looking for the perfect gift?* Give the gift of Flickr!*<http://www.flickr.com/gift/>