I have an application using JDBC. But for some reasons 9we are using Singleton on DAO's) I cannot use the JDBC for manage the isolation (con.setTransactionIsolation(int)). So what can I do to solve this?
The solution is probably to stop using the singleton pattern. Arguably the most over-used and misunderstood pattern in the GOF book. Somebody has ensured that you can't make dynamic configuration changes to your DAO without impacting somebody else. If the impact on others (e.g. in other threads of execution) is what you are trying to avoid while changing the transaction isolation level for your own use, unfortunately you are hosed.
How useful is it anyway to change the isolation level? For instance, I believe that Oracle only supports two levels: TRANSACTION_READ_COMMITED (the default) and TRANSACTION_SERIALIZABLE (which you won't normally want to use).
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Reid M. Pinchback
Joined: Jan 25, 2002
Good point. The situation is a bit more complex if you are using something like Weblogic CMP even with Oracle, but for Dao's using JDBC directly, you are correct. There doesn't seem a good reason for mucking with that setting.
Do I understand you right that your architecture includes read-write Singletons accessed from EJBs? If that is the case your architecture is going against the EJB spec. I'd find out why Singletons are required - sounds a little strange to me.
With sure the Singleton was not a good idea, but the project is runnning, so I cannot change now... hehehe And the point is: I need to guarantee the isolation of transaction, I cannot admit data inconsistency. So I want to know what's the easily solution?
Humm, another thing: I'm using EJB CMP, so I cannot use JTA. Another, I'm using the JBoss, I heard that don't have tools to manage isolation (WebLogic have)
Somebody have another idea? Or maybe I have a big problem here? hehehe
Joined: Sep 29, 2002
With sure the Singleton was not a good idea, but the project is runnning, so I cannot change now... hehehe
It's still not clear why you can't make a change.
Humm, another thing: I'm using EJB CMP, so I cannot use JTA.
All container-managed EJB transactions are JTA transactions.