Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

default transaction attribute for CMP

 
Edy Yu
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I don't specify the transaction attributes in the deployment descriptor, what are the default transaction attributes for my CMP beans?
Thanks in advance...
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no default transaction setting:
EJB 2.0 Specification, Section 17.5
The Deployer is responsible for ensuring that the methods of the deployed enterprise beans with container-managed transaction demarcation have been assigned a transaction attribute. If the transaction attributes have not been assigned previously by the Assembler, they must be assigned by the Deployer.

If you do not specify a transaction attribute for methods in an EJB then it's transactional behavior will depend on the particular EJB Container that you are using. Therefore, for portability you should always specify a transaction setting for your EJBs.
[ June 24, 2003: Message edited by: Chris Mathews ]
 
Nagendra Prasad
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry if this question is a bit behind EJB2.0... but .. assuming (Thats dangerous.. I know).. that the spec for EJB 1.1 was similar, i.e if transaction not specifically set, then container can assume the default it chooses right.
Mostly, we have followed a pattern wherein we do not set it of the method does not need a transaction.
Would it be better in these cases to have the setting at 'Never' instead? Would that provide any advantage?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic