Hello,
I am experiencing a problem whereby I begin a new transaction and attempt to save an object, I run into a RollBackException. The code for persisting my object is roughly the following:
Session s = sfac.openSession();
org.hibernate.Transaction tx = null;
try {
tx = s.beginTransaction();
s.save(batch)
However, upon calling save() I consistently get an exception informing me that the transaction has already been marked for rollback. (It might also be of importance that upon calling s.beginTransaction() a WARN is given by TransactionImpl: Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=Inspiron-Nick/72, BranchQual=, localId=72] timed out. status=STATUS_ACTIVE). tx.wasRolledBack() also does not indicate that the transaction has been rolled back.
Now, the highly strange thing is, I can only replicate this if I have just called a CMT bean (in a completely separate client call) which throws a test exception I have generated (this is *all* it does) and hence marks its CMT transaction for rollback. This has me baffled because I cannot see how the two transactions should be related (other than the fact that they are running in the same JBoss container).
Is it possible in some way that beginTransaction would load up a JTA transaction that has yet to tidy up, instead of producing a new one?
Now, to try and isolate the problem, I used a JTA UserTransaction from JNDI instead of the code above - and this completely fixed the problem! I was not able to replicate it at all using
I am using hibernate 3.1.3, running on JBoss 4.0.3SP1, attached to MS SQL Server 2000.
Any feedback or insight into the problem would be greatly appreciated: I've only started using hibernate over the last month and want to be certain I haven't misunderstood some key concepts.
Regards,
Nick
|