Clinton,
I'll do as you suggest and attach the file.
Thanks for your help.
Jeff
--- Clinton Begin <[EMAIL PROTECTED]> wrote:
> I believe the fix you've made this time (i.e. commit
> in started or committed
> state) is acceptable, and probably something we
> could include in the base.
>
> Can you open a JIRA "bug" and attach your modified
> file?
>
> Thanks much,
>
> Clinton
>
> On 11/30/05, Jeff Roberts
> <[EMAIL PROTECTED]> wrote:
> >
> > Clinton,
> > Thank you for the instructions. I changed my code
> to
> > do as you suggest, that is issue one start and
> > multiple commits, followed by an end. However, on
> the
> > second commit, I get an exception (shown below).
> >
> >
> com.ibatis.common.jdbc.exception.NestedSQLException:
> > Could not commit transaction. Cause:
> >
>
com.ibatis.sqlmap.engine.transaction.TransactionException:
> > TransactionManager could not commit. No
> transaction
> > is started.
> >
> > In looking at the commit method in
> TransactionManager,
> > it's clear why this happened. A commit is only
> > allowed if the Transaction state is STATE_STARTED.
> > See below:
> >
> > public void commit(SessionScope session) throws
> > SQLException, TransactionException {
> > Transaction trans = session.getTransaction();
> > TransactionState state =
> > session.getTransactionState();
> > if (state ==
> TransactionState.STATE_USER_PROVIDED)
> > {
> > throw new
> > TransactionException("TransactionManager could not
> > commit. " +
> > "A user provided connection is currently
> > being used by this session. " +
> > "You must call the commit() method of
> the
> > Connection directly. " +
> > "The calling .setUserConnection (null)
> will
> > clear the user provided transaction.");
> > } else if (state !=
> > TransactionState.STATE_STARTED) {
> > throw new
> > TransactionException("TransactionManager could not
> > commit. No transaction is started.");
> > }
> > if (session.isCommitRequired() || forceCommit)
> {
> > trans.commit();
> > session.setCommitRequired(false);
> > }
> >
> >
>
session.setTransactionState(TransactionState.STATE_COMMITTED);
> > }
> >
> >
> > When the first commit was issued, it worked
> properly
> > and set the Transaction state to STATE_COMMITTED.
> If
> > you don't want to decrement the throttle inside of
> > commit, I assume the remedy would be to change the
> > commit method to allow a commit if the Transaction
> > state is either STATE_STARTED or STATE_COMMITTED.
> >
> > I've changed the code and verified that this
> works,
> > but not sure if this is the solution you would
> advise.
> > In a previous note, you advised calling start,
> > commit, end in sequence, iteratively. I may be
> > mistaken, but thought that calling end released
> the
> > connection. If that is the case, I'd rather not
> do it
> > that way as I loop in my code many times and would
> > rather not release and re-acquire connections
> > repeatedly.
> >
> > Thank you,
> > Jeff Roberts
> >
> > --- Clinton Begin <[EMAIL PROTECTED]> wrote:
> >
> > > PS: You should be able to call commit multiple
> > > times, without re-calling
> > > start...that should allow you to do what you
> want.
> > > (i.e. don't call start
> > > multiple times).
> > >
> > > On 11/30/05, Clinton Begin
> <[EMAIL PROTECTED]>
> > > wrote:
> > > >
> > > >
> > > > Jeff,
> > > >
> > > > Commit should not be decrementing the
> throttle.
> > > Instead,
> > > > .endTransaction() should be called for every
> call
> > > to .startTransaction().
> > > >
> > > > Even if commit is called, end should be called
> > > too.
> > > >
> > > > Cheers,
> > > > Clinton
> > > >
> > > > On 11/30/05, Jeff Roberts
> > > <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > I have encountered what I believe to be a
> bug
> > > in the TransactionManager
> > > > > class. It appears to me that the commit()
> > > method should be doing a
> > > > > txThrottle.decrement(). A slight change to
> the
> > > end() method is required
> > > > > as well to prevent too many decrement()
> calls.
> > > > >
> > > > > I have fixed the code and verified that it
> > > works, but wanted to make
> > > > > sure that what I found is in fact a bug and
> not
> > > misuse of the
> > > > > TransactionManager.
> > > > >
> > > > > I have a long running job and am using
> iBatis.
> > > This job does numerous
> > > > > startTransaction(), commitTransaction()
> > > iterations. What is happening, is
> > > > > that each of my startTransaction() calls
> > > increments the throttle through the
> > > > > begin() method on TransactionManager. When
> I
> > > commit, I would expect this to
> > > > > decrement the throttle, but it doesn't.
> > > Eventually, my code iterates enough
> > > > > times that it increments the throttle and I
> end
> > > up in a wait that never
> > > > > ends.
> > > > >
> > > > > If it is deemed a bug, I 'm happy to submit
> my
> > > fix through Jira. For
> > > > > clarification, here is what I did to fix the
> > > problem.
> > > > >
> > > > > Class
> > >
> >
>
com.ibatis.sqlmap.engine.transaction.TransactionManager
> > > > >
> > > > > First, I modified the commit method as shown
> > > below. I've commented the
> > > > > line that I added.
> > > > >
> > > > > public void commit(SessionScope session)
> throws
> > > SQLException,
> > > > > TransactionException {
> > > > > Transaction trans =
> > > session.getTransaction();
> > > > > TransactionState state =
> > > session.getTransactionState();
> > > > > if (state ==
> > > TransactionState.STATE_USER_PROVIDED) {
> > > > > throw new
> > > TransactionException("TransactionManager could
> not
> > > > > commit. " +
> > > > > "A user provided connection is
> > > currently being used by this
> > > > > session. " +
> > > > > "You must call the commit() method
> of
>
=== message truncated ===
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com