Transaction Semantics for Stateful Session Beans Transaction Semantics for Stateless Session Beans

Transactions in EJB Applications 8-5

8.5.1.3 Transaction Semantics for Entity Beans

Table 8–3 describes the transaction semantics for entity beans in container-managed transactions.

8.5.2 Transaction Semantics for Bean-Managed Transactions

For bean-managed transactions, the transaction semantics differ between stateful and stateless session beans. For entity beans, transactions are never bean-managed.

8.5.2.1 Transaction Semantics for Stateful Session Beans

Table 8–4 describes the transaction semantics for stateful session beans in bean-managed transactions. setSessionContext Unspecified No ejbCreate Unspecified No ejbRemove Unspecified No Business method Yes or No based on transaction attribute No Table 8–3 Transaction Semantics for Entity Beans in Container-Managed Transactions Method Transaction Context at the Time the Method Was Invoked Can Access UserTransaction Methods? Constructor Unspecified No setEntityContext Unspecified No unsetEntityContext Unspecified No ejbCreate Determined by transaction attribute of matching create No ejbPostCreate Determined by transaction attribute of matching create No ejbRemove Determined by transaction attribute of matching remove No ejbFind Determined by transaction attribute of matching find No ejbActivate Unspecified No ejbPassivate Unspecified No ejbLoad Determined by transaction attribute of business method that invoked ejbLoad No ejbStore Determined by transaction attribute of business method that invoked ejbStore No Business method Yes or No based on transaction attribute No Table 8–2 Cont. Transaction Semantics for Stateless Session Beans in Container-Managed Transactions Method Transaction Context at the Time the Method Was Invoked Can Access UserTransaction Methods? 8-6 Programming JTA for Oracle WebLogic Server

8.5.2.2 Transaction Semantics for Stateless Session Beans

Table 8–5 describes the transaction semantics for stateless session beans in bean-managed transactions.

8.6 Session Synchronization

A stateful session bean using container-managed transactions can implement the javax.ejb.SessionSynchronization interface to provide transaction synchronization notifications. In addition, all methods on the stateful session bean must support one of the following transaction attributes: REQUIRES_NEW, MANDATORY or REQUIRED. For more information about the javax.ejb.SessionSynchronization interface, see Section 6.5.3 in the EJB Specification 2.1. Table 8–4 Transaction Semantics for Stateful Session Beans in Bean-Managed Transactions Method Transaction Context at the Time the Method Was Invoked Can Access UserTransaction Methods? Constructor Unspecified No setSessionContext Unspecified No ejbCreate Unspecified Yes ejbRemove Unspecified Yes ejbActivate Unspecified Yes ejbPassivate Unspecified Yes Business method Typically, no unless a previous method execution on the bean had completed while in a transaction context Yes afterBegin Not applicable Not applicable beforeCompletion Not applicable Not applicable afterCompletion Not applicable Not applicable Table 8–5 Transaction Semantics for Stateless Session Beans in Bean-Managed Transactions Method Transaction Context at the Time the Method Was Invoked Can Access UserTransaction Methods? Constructor Unspecified No setSessionContext Unspecified No ejbCreate Unspecified Yes ejbRemove Unspecified Yes Business method No Yes