Java Reference
In-Depth Information
Figure 4-3. The REQUIRED transaction propagation behavior
However, if the purchase() method is called by a non-transactional method and there's no existing
transaction in progress, it will start a new transaction and run within its own transaction.
The propagation transaction attribute can be defined in the @Transactional annotation. For
example, you can set the REQUIRED behavior for this attribute as follows. In fact, this is unnecessary,
because it's the default behavior.
package com.apress.springenterpriserecipes.bookshop.spring;
...
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
public class JdbcBookShop extends JdbcDaoSupport implements BookShop {
...
@Transactional( propagation = Propagation.REQUIRED)
public void purchase(String isbn, String username) {
...
}
}
package com.apress.springenterpriserecipes.bookshop.spring;
...
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
public class BookShopCashier implements Cashier {
...
@Transactional( propagation = Propagation.REQUIRED)
public void checkout(List<String> isbns, String username) {
...
}
}
Search WWH ::




Custom Search