I am referring to container managed transaction attributes in Enterprise Java Beans. I can't think of any use cases where using 'Mandatory' and 'Never' makes sense. Can anyone please explain what cases warrant using these transaction attributes?
I worked with a project recently that insisted that all transactions were marked out at the application layer (the service classes), and that Data Access Objects must not be called directly.
This was to ensure that the database wasn't ever written to without the associated application logic being invoked (usually, the database operation was paired up with a message sent to queue).
An application of MANDATORY on every DAO EJB ensured that whilst they would run in a transaction, it was the job of a caller to start one. Since the DAOs were called by the service classes (which had the default of REQUIRED), this meant that they worked just fine but anybody accidentally calling them directly would be rewarded with an exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With