Because of the duration of some transactions, we need to exclude read only access to EB from the current transaction.
This is usely done with setting the trans-attribute to 'RequiresNew' for get methods.
But this easy lead to deadlocks. If in a transaction two clints calls a EB, fist one a set method then second one a get, u get immediately a deadlock.
Needed would be a trans-attribute which use the current transaction, if the bean is locked in this one and calls the method in a new otherwise.
Is there a workaround for this problem or a better design pattern which avoid the problem?
Well here is how we are doing it.
First all entity beans are accessed via session beans.
The readonly or “get” method in the session beans have the trans-attribute set to NotSupported. The write methods or “sets” are “RequiresNew”. And all methods in the enitity beans are set to “Supports”.
BTW: We are using 2.4.1 and HSQL