@Inherited
@InterceptorBinding
@Target(value={TYPE,METHOD})
@Retention(value=RUNTIME)
public @interface Transactional
The Transactional annotation specifies whether the container is to invoke a business method within a transaction context. Note that it can only be used on CDI managed beans because it relies on a CDI Interceptor to manage the transaction.
The annotation can be specified on the bean class and/or it can be specified on methods of the class.
Specifying the Transactional annotation on the bean class means that it applies to all applicable methods of the class. Specifying the annotation on a method applies it to that method only. If the annotation is applied at both the class and the method level, the method value overrides if the two disagree.
Example of a bean where all method calls are invoked within the context of a transaction:
package demo;
import javax.enterprise.inject.Default;
import oracle.webcenter.portal.transaction.Transactional;
@Default
@Transactional
public class Demo
{
public void doSomething()
{
// Invoked within a transaction context
}
public void doSomethineElse()
{
// Invoked within a transaction context
}
}
Example of a bean where only one method is marked as being invoked within the context of a transaction:
package demo;
import javax.enterprise.inject.Default;
import oracle.webcenter.portal.transaction.Transactional;
@Default
public class Demo
{
@Transactional
public void doSomething()
{
// Invoked within a transaction context
}
public void doSomethineElse()
{
}
}
Modifier and Type | Optional Element and Description |
---|---|
Propagation |
propagation
The values of the propagation attribute of the Transactional annotation are defined by the enum
Propagation . |
public abstract Propagation propagation
Propagation
. If the value is not specified, the semantics of the REQUIRED transaction propagation are
assumed.