michael wrote:
If you don't have a guarantee that you have a thread-per-transaction association using threadlocal becomes dangerous of course. Either you do manual passing around of your sesison, or you find another way to bind your session to the transaction scope in a way you can use in your situation.
Thank you for reply.
I have another problem with Threads, Transactions and Sessions!
I have applied DAO pattern and I have some DAO classes which are responsible to handle all the entity's life cycle. On the other hand, I use SFSB's for Session Facade.
There'll be no problem in ONE transaction but imagin a situation where in transaction 1 I find the bean (through its DAO1 and using ThreadLocal for getting the session)and keep the entity object (bean) as a SFSB's member. In transaction 2, when I use another DAO2, given session is different to the first. This causes some problems for developers.
I think I need session-per-SFSB !!! and pass the session manually to all DAO's. I prefered not to show the session to the developers before.
What's your idea about this conflict? Which situation is better?
Thanks in advance,
Amin Emami