nerdexam
Oracle

1Z0-895 · Question #92

A developer implements a CMT session bean with a method storeBoth which inserts data both a related database and an LDAP server. The relational database supports transactions while the LDAP system…

The correct answer is C. Define the transaction attribute of the method storeBoth as REQUIRED_NEW. Carry out the database. The method should start a new transaction, so we use theREQUIRED_NEWattribute. For the LDAP operation we can only detect LDAP exceptions. We cannot check the status of the LDAP operation throughSessionContext.getRollBackOnly. CMT -Container-Managed Transactions RequiresNew…

Transactions

Question

A developer implements a CMT session bean with a method storeBoth which inserts data both a related database and an LDAP server. The relational database supports transactions while the LDAP system does NOT. Given that both updates should succeed or be rolled back, while is the best solution?

Options

  • AImplement the SessionSynchoronization interface in the session bean. In the afterCompleteion method,
  • BDefine the transaction attribute of the method storeBoth as REQUIRED. The container manages the
  • CDefine the transaction attribute of the method storeBoth as REQUIRED_NEW. Carry out the database
  • DDefine the transaction attribute of the method storeBoth as REQUIRED_NEW. Carry out the LDAP

How the community answered

(47 responses)
  • A
    6% (3)
  • B
    4% (2)
  • C
    79% (37)
  • D
    11% (5)

Explanation

The method should start a new transaction, so we use theREQUIRED_NEWattribute. For the LDAP operation we can only detect LDAP exceptions. We cannot check the status of the LDAP operation throughSessionContext.getRollBackOnly. * CMT -Container-Managed Transactions *RequiresNew Attribute If the client is running within a transaction and invokes the enterprise bean's method, the container takes the following steps: Suspends the client's transaction Starts a new transaction Delegates the call to the method Resumes the client's transaction after the method completes If the client is not associated with a transaction, the container starts a new transaction before running the method. You should use the RequiresNew attribute when you want to ensure that the method always runs within a new transaction. The Java EE 5 Tutorial,Container-Managed Transactions

Topics

#CMT transaction attribute#REQUIRED_NEW#non-transactional resource#LDAP compensation

Community Discussion

No community discussion yet for this question.

Full 1Z0-895 Practice