my dog learned polymorphism
The moose likes EJB and other Java EE Technologies and the fly likes CMT & Transaction Attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMT & Transaction Attribute" Watch "CMT & Transaction Attribute" New topic

CMT & Transaction Attribute

Johnson Tmmet

Joined: Oct 27, 2005
Posts: 8
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
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

Joined: Feb 17, 2005
Posts: 704
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).

I think, therefore I exist -- Rene Descartes
I agree. Here's the link:
subject: CMT & Transaction Attribute
It's not a secret anymore!