April 2018
Intermediate to advanced
382 pages
10h 11m
English
The key code line in this recipe for JTA is right here:
<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 would run into a rollback if there's ...
Read now
Unlock full access