The EJB transaction attribute can be one of several values:
Required,requiresnew,mandatory,notsupported,supports,never.
1, Required
If the customer runs in an EJB transaction, and the method in the EJB is invoked, the method runs in the EJB transaction of the client. If the client is not associated with an EJB transaction, the container starts a new EJB transaction before it runs the method. The required attribute is suitable for most EJB transactions, and it is recommended that it be set to default, at least in the development phase. EJB transaction attributes are declarative and can be easily modified later.
2, RequiresNew
If the client is running in an EJB transaction and the method in the EJB is invoked, the container takes the following actions:
(1) Suspend client EJB transaction
(2) Start a new EJB transaction
(3) Delegate the call to the method
(4) After the execution of the method, reply to the client EJB transaction
If the client is not associated with an EJB transaction, the container starts a new EJB transaction before it runs the method. If you ensure that the method always runs in a new EJB transaction, you should use the RequiresNew property.
3, mandatory
If the client is running in an EJB transaction and the method in the EJB is invoked, the method runs in the client EJB transaction. If the client is not associated with an EJB transaction, the container throws a transactionrequiredexception. If the method in the EJB must use the client's EJB transaction, the mandatory attribute should be used.
4, NotSupported
If the client is running in an EJB transaction and the method in the EJB is invoked, the container suspends the client EJB transaction and then replies to the client EJB transaction after the method is called. If the client is not associated with an EJB transaction, the container does not start the EJB transaction until the method is run. This property can be considered for methods that do not require an EJB transaction. EJB transactions require a certain amount of overhead, notsupported properties can improve performance.
5, Supports
If the client is running in an EJB transaction and the method in the EJB is invoked, the method runs in the client's EJB transaction. If the client is not associated with an EJB transaction, the container does not start a new EJB transaction before it runs the method.
6, Never
If the client is running in an EJB transaction and the method in the EJB is invoked, the container throws a RemoteException exception. If the client is not associated with an EJB transaction, the container does not start a new EJB transaction until it runs the method.