I am using Spring inside an EJB (on Weblogic). Until now I was using one database only and everything was nice. The EJB had a 'transaction required' attribute. Now I have to run also a query against an archive database inside one method. As this is a SELECT to a read-only database then I don't want XA connections. So I thought I could suspend the production DB transaction while running the archive query. I am using JdbcTemplate (through JdbcOperations interface). As this is a simple query, I didn't want to create a separate bean for that. I tried to wrap the JdbcTemplate with TransactionProxyFactoryBean. I have these declarations:
This seems to work ok. Just a few questions:
<bean id="archiveDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<bean id="archiveJdbcOperations" class="org.springframework.jdbc.core.JdbcTemplate">
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/>
<bean id="wrappedArchiveJdbcOperations" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target"><ref bean="archiveJdbcOperations"/></property>
- is it a good idea to wrap JdbcTemplate like this?
- although my code works, there is one exception internally - when the JdbcTemplate initializes, it uses the SQLErrorCodesFactory to get database metadata and the TransactionProxyFactoryBean is not working then yet and Weblogic throws an exception:
How could I get around this? I know that my database is Oracle so maybe I could somehow tell my JdbcTemplate that and skip the metadata loading?
Connection has already been created in this tx context.