Hi Ranchers,
i have a few questions about Exceptions and "Container Managed Transactions", note that I have a good idea about the answers but I hope precise and convincing answers. Thanks in Advance Ranchers!
1) An ApplicationException (CreateException, NotEnaughMoneyInAccount, FinderException...) thrown by a bean does not rollback the transaction , Why ? For instance, if the transaction was started by a stateless session bean "S" and if "S" throws an ApplicationException, why should I want to commit the transaction. Moreover, that means also that if a client of an entity bean receives a CreateException, the client has no idea if the database insert was successful. Too bad, isn't it ?
2) What is the need for setRollbackOnly if I want the running transaction to rollback ? Why not just throwing a SystemException (that will cause an automatic rollback) . Moreover, instead of relying on the other beans checking the "rollback only flag" with getRollbackOnly to avoid lenghty tasks, is throwing a SystemExcption not easier ? (OK! One argument against throwing a SysEx is that beans state may become corrupted, but an Entity Bean will resync with the DB at next method call, and a stateless bean will be reset, so this affects only Stateful beans ? Right ?)
3) When do I need SessionSynchronization and what would I want to put in afterBegin, beforeCompletion, afterCompletion (Tell me a use case please). Only Stateful session beans should need afterCompletion, in order to leave the bean in a clean state for the client when he calls the next method ?
4) Other question not about transactions but a general purpose question. With the "remote call procedure paradigm" i always have to get a "stub reference" to an object in order to call a method ? Is that not a performance problem?
I know my questions are a bit long.
Thank you if you read so far.
[ January 02, 2009: Message edited by: Jean-Luc Thirion ]
[ January 02, 2009: Message edited by: Jean-Luc Thirion ]