aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Transaction confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Transaction confusion" Watch "Transaction confusion" New topic
Author

Transaction confusion

Christiaan Pansegrouw
Greenhorn

Joined: Dec 14, 2004
Posts: 9
Hi All

I hope my question makes sense .. . .

In the EJB HeadFirst on p509 they say for CMT: Compulsory for entity beans.

Now . . . I have been using entity beans (and session beans for that matter) without using a single <container-transaction > in the <assembly-descriptor> section in my DD(ejb.jar). Does the container automaticly use the 'Required' attribute for ALL the buisiness methods for a entity bean? (I am using JBoss btw).

As for the session beans , <transaction-type>Container/Bean</transaction-type> is always present in the <enterprise-beans> section , but what if nothing for that bean is spesified in <container-transaction > in the <assembly-descriptor> section - does the methods run in no transaction or is it also 'Required' for all by default ?

Regards

Christiaan
Keerthi P
Ranch Hand

Joined: Aug 19, 2003
Posts: 203
but what if nothing for that bean is spesified in <container-transaction > in the <assembly-descriptor> section - does the methods run in no transaction or is it also 'Required' for all by default ?


That is solely upto the container implementation. The spec does not guarantee what the transaction will be if the attribute is not specified.


Cheers.<br />Keerthi<br />(SCJP, SCWCD, SCBCD)
Christiaan Pansegrouw
Greenhorn

Joined: Dec 14, 2004
Posts: 9
Thanks , but what about the comment :

CMT is Compulsory for entity beans.

does this mean that you can ONLY use CMT for entity bean , or CMT should ALWAYS be used for entity beans - or is this also up to your ejb-container's mercy ?
sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
Entity Beans can Use only CMT. The treansaction attribute if not specified then it depends upon the container. Weblogic 8.1 uses Supports as default. Not sure about jboss.

cheers


Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Christiaan Pansegrouw
Greenhorn

Joined: Dec 14, 2004
Posts: 9
can you choose not to use transactions for entity beans - ie. it is not a must to use transactions.
sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
This is a intresting question . The EJBLoad and EJBStore methods are called with the start of a new transaction and not with every method call . That means on the basis of the transaction the container decides when to load and store.

I am not very sure but for select and finder methods specifiying no transaction makes sense but for other things we definitely need transactions.
Miki Muzsi
Ranch Hand

Joined: Jun 23, 2003
Posts: 120
I am not very sure but for select and finder methods specifiying no transaction makes sense

In a way it does make sens. Suppose we have CMR fields that are loaded. If we are not in a transaction, the data that is loaded can be "inconsistent" by the time we finish initializing an entity...

Miki


Miki<br /> <br />SCJP 1.4, SCBCD 1.3
 
Don't get me started about those stupid light bulbs.
 
subject: Transaction confusion
 
Similar Threads
Deployment time NameNotFoundException
Stateless EJB and transactions
Transaction attributes
error while deploying ejb in jboss
Problems deploying an entity bean