Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BMT/CMT and JDBC Transaction

 
King Hong Chan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between BMT UserTransaction/CMT and JDBC Transaction?

So does the database be updated finally by the following?

UserTransaction.begin();
//some db update code
Connection.commit();
UserTransaction.rollback();
 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the spec 17.3.3, you are not supposed to use Connection.commit() :

The Bean Provider uses the UserTransaction interface to demarcate transactions. All updates to the resource managers between the UserTransaction.begin() and UserTransaction.commit() methods are performed in a transaction. While an instance is in a transaction, the instance must not attempt to use the resource-manager specific transaction demarcation API (e.g. it must not invoke the commit() or rollback() method on the java.sql.Connection interface or on the javax.jms.Session interface).
 
King Hong Chan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So will there be an exception or just the target database is updated even the user transaction is rollback?
 
King Hong Chan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moreover, if there is any definition in the deployment descriptor, what is the default transaction attribute for the CMT beans?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic