Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMT & Transaction Attribute

 
Johnson Tmmet
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I use CMT.

1. In my EJB method, I simply delete a record from the Oracle database
using sql query.Which transaction attribute would be appropriate in this
case?
I guess 'NotSupported' is appropriate as I don't have multiple sql queries
to delete.

2. Also, in the same page, when I call a single select sql query from my
EJB method, I can use 'NotSupported'.
3.When I have a simple insert / update sql query(only insert/update in one
table), I can use 'NotSupported'.

4.When I have to insert / update multiple sql queries in my EJB
method,other transaction attributes would be appropriate.

Please let me know whether the above are correct.
Thanks in advance,
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Johnson,

As a rule of thumb NotSupported should be used when an enterprise bean accesses a resource manager that doesn�t support transactions. Don�t use NotSupported for any other reason, since the result might be unpredictable. Any database update/delete/insert operation needs to run within a transaction that commits at the end, in order to update the database. Don�t believe that transactions are needed only when two or more operations must execute as a unit (which is the meaning of transactions). This is an EJB container which was entirely architected and designed to perform any work within a transactional context.
Finally I would say that you should rather use the required attribute (which for many application could be considered the default).
Regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic