Originally posted by Jonathan Harker: Would it affect Container Managed Transactions in any way? 1. When ejb - method starts its own transaction. 2. When it inherits a tx.
I think you won't be able to rollback the transaction programatically, as setRollBackOnly() method is present in SessionContext (the reference of which you are not saving), otherwise i don't think there should be any problem.
Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
You must save the sessionContext (or any other bean contexts), This is the only way that your bean can be aware of it's environment. If you fail to do so, you won't get another chance to refrence it later. This is a must for the bean provider. (best practice).
Originally posted by schrodinger's cat: This is the only way that your bean can be aware of it's environment. This is a must for the bean provider.
Ah, but you've contradicted yourself. Let me rephrase your statements:
Storing the context reference is a must for the bean provider in order to be aware of its environment.
So, if you don't need any of the methods exposed by the context (rolling back transactions programatically in CMT, for example), then clearly you don't need to store the context. Granted, I don't see much reason not to include the member field and one-line method needed to store the context, but it's not mandatory that you do.