- Jakarta EE Cookbook
- Elder Moraes
- 114字
- 2021-06-24 16:12:46
How it works...
The key code line in this recipe for JTA is as follows:
<persistence-unit name="ch02-jta-pu" transaction-type="JTA">
When you use transaction-type='JTA', you are saying to the server that it should take care of all transactions made under this context. If you use RESOURCE-LOCAL instead, you are saying that you are taking care of the transactions:
@Test
public void validTransaction() throws Exception{
User user = new User(null, "Elder Moraes",
"elder@eldermoraes.com");
userBean.add(user);
user.setName("John Doe");
userBean.update(user);
User userDb = userBean.findById(1L);
assertEquals(userDb.getName(), "John Doe");
}
Each called method of UserBean starts a transaction to be completed and will run into a rollback if there's an issue while the transaction is alive. This would be committed to the end of it.
推薦閱讀
- ASP.NET MVC4框架揭秘
- Rust編程:入門、實戰與進階
- 無代碼編程:用云表搭建企業數字化管理平臺
- Python測試開發入門與實踐
- Object-Oriented JavaScript(Second Edition)
- Podman實戰
- 零基礎學Java(第4版)
- Python編程從0到1(視頻教學版)
- 批調度與網絡問題的組合算法
- CoffeeScript Application Development Cookbook
- Python Data Science Cookbook
- 計算機應用基礎教程(Windows 7+Office 2010)
- QGIS 2 Cookbook
- 算法設計與分析:基于C++編程語言的描述
- Python Digital Forensics Cookbook