The EJB specification says that we cannot use Bean Managed Transaction in Entity Beans. Why?
– The short, practical answer is� because it makes your entity beans useless as a reusable component. Also, transaction management is best left to the application server – that�s what they�re there for. It�s all about atomic operations on your data. If an operation updates more than one entity then you want the whole thing to succeed or the whole thing to fail, nothing in between. If you put commits in the entity beans then it�s very difficult to rollback if an error occurs at some point late in the operation.
Related Questions
- If I throw a custom ApplicationException from a business method in Entity bean which is participating in a transaction, would the transaction be rolled back by container?
- With regard to Entity Beans, what happens if both my EJB Server and Database crash, what will happen to unsaved changes? Is there any transactional log file used?
- My session beans call other bean methods within a transaction. Using bean-managed transactions, how should I take care of commit and rollback ?