Hi!
----- Original Message -----
From: Aaron Mulder <[EMAIL PROTECTED]>
To: jBoss Developer <[EMAIL PROTECTED]>
Sent: Sunday, July 30, 2000 3:24 PM
Subject: RE: [jBoss-Dev] TransactionImpl
> much you can do to work around this. There is no way you can tell a
> Connection which Xid or Transaction it should be associated with - there's
> a one-to-one mapping. We planned to set it up so that if you're using the
> wrapper, you can only get one connection for any particular Xid.
> The problem with this is that the desired result isn't clear: you
> can either return the same connection object for every request, or throw
> an exception for all requests after the first. In the first case, it's
> not clear how to handle closing (does the connection close after the first
> or last close call?). In the second case, you may be prevented from doing
> some legitimate things (using one table in two beans, and you can't really
> pass the connection from one to the other).
I think the first choice is the right one. The second approach is too much
restrictive and less transparent for the application. You should return the
connection to the pool after the first close that is outside of any
transaction.
Using always the same jdbc 1 connection for the same transaction on the same
resource manager will avoid the problem of comitting more than once in that
resource manager for that transaction.
But the algorithm:
public boolean enlistResource(XAResource xaRes)
throws RollbackException
{
// Check rollback only
if (status == Status.STATUS_MARKED_ROLLBACK)
{
throw new RollbackException();
}
// Add resource
try {
xaRes.start(xid, Status.STATUS_ACTIVE);
resources.addElement(xaRes);
return true;
} catch(XAException e) {
e.printStackTrace();
return false;
}
}
and the related commit one that I posted last week are still wrong for real
distributed drivers for which the restrictions above don't apply. I think
isSameRM should be asked before enlisting the xa resource (if I remember it
well the JTS spec says exactly this). This should work with both types of
drivers.
> Aaron
Carlos.