cancel
Showing results for 
Search instead for 
Did you mean: 

transaction example question (from user guide)

beep02
Champ in-the-making
Champ in-the-making
    In the example:

    // here you can do transactional stuff in your domain model
    // and it will be combined in the same transaction as
    // the startProcessInstanceByKey to the Activiti RuntimeService

public class UserBean {

  /** injected by Spring */
  private RuntimeService runtimeService;

  @Transactional
  public void hello() {
   
    runtimeService.startProcessInstanceByKey("helloProcess");
  }
 
  public void setRuntimeService(RuntimeService runtimeService) {
    this.runtimeService = runtimeService;
  }
}

Question:
In the example:
Originated transaction started, once @Transactional encountered in the user bean.
Then Process transaction context taken from the originated transaction.

Is it working in opposite way, example:
Suppose we have a process instance, starting NOT in the bean, like in the example above,but that uses this UserBean from, say, some ServiceTask within the process.
Is transaction context taken from the process instance and used in the method call of UserBean?

1 REPLY 1

jbarrez
Star Contributor
Star Contributor
Yes. If the bean is marked with @Transactional, and activiti has been configured with a correct and working transactionManager, this will use the same transaction