Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EJB are transactional components. The transaction can be managed either by the applicaiton server itself (CMT - container-managed transaction), or manually by yourself within the EJB (BMT - bean-managed transaction).</p> <p>EJB supports distributed transaction through the JTA specification. The distributed transaction is controlled using <a href="http://java.sun.com/products/jta/javadocs-1.0.1/javax/transaction/UserTransaction.html" rel="noreferrer"><code>UserTransaction</code></a>, which has methods <code>begin</code>, <code>commit</code>, <code>rollback</code>.</p> <p>With CMT, the application server starts, commit and rollback the transaction (according to the <a href="http://java.sun.com/products/ejb/javadoc-3_0-fr/javax/ejb/TransactionAttributeType.html" rel="noreferrer">transaction annotations</a>) for you and you are not allowed to interfere. This means you must not access the <code>UserTransaction</code> in this case. However, with BMT, you do that manually and you control the transaction yourself using the <code>UserTransaction</code>.</p> <p>Let's move now to the <code>EntityManager</code>. A JPA implementation can be used either within an application server or stand-alone. If use in stand-alone, you need to use <code>EntityManage.getTransaction</code> to demarcate the JDBC transaction yourself. If used within an application server, the <code>EntityManager</code> cooperated with the JTA distributed transaction manager transparently for you. </p> <p>Most of the time, you use CMT with <code>@Required</code> annotation on the EJB. This means that you don't need to access neither <code>UserTransaction</code> nor <code>EntityManager.getTransaction</code>. The app. server starts and commits the transaction, but also takes care to rollback if an exception is raised. This is what I would recommend for your facade.</p> <p>(There are more subtleties, such as the <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/PersistenceContextType.html#TRANSACTION" rel="noreferrer"><code>PersistenceContextType</code></a> or the manual enlistment of the entity manager in distributed transaction with <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#joinTransaction%28%29" rel="noreferrer"><code>EntityManager.joinTransaction</code></a>, but that's only if you use the technologies in a different ways as the default).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload