Best Practices

The J2EE architecture encourages the use of container-managed transaction demarcation. It's the preferred approach over bean-managed transaction. Use container-managed transaction demarcation unless you have a specific need for bean-managed transactions. CMT should be used wherever possible to minimize the overhead of writing code to a transaction management service API. Not only will this result in less work for you as a programmer, but it will also reduce the possibility of errors in the final code. For example, it will keep you from accidentally not committing a transaction or committing too early. It also enables you to change the behavior without programmatic changes. Never demarcate transactions from an EJB with container-managed ...

Get Sams Teach Yourself EJB in 21 Days now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.