Things seem to work if I use a separate ConnectionManager with each datasource. Is there any way around this. or is this the desired behavior?
<!-- ###### CONFIG Connection Manager ###### -->
<bean id="configConnectionManager"
class="org.jencks.factory.ConnectionManagerFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
<!-- ###### CONFIG JDBC Data Source ###### -->
<bean id="configDataSource"
class="org.jencks.factory.ConnectionFactoryFactoryBean">
<property name="managedConnectionFactory"
ref="configJDBCManagedConnectionFactory" />
<property name="connectionManager" ref="configConnectionManager" />
</bean>
<!-- ###### LIVE Connection Manager ###### -->
<bean id="liveConnectionManager"
class="org.jencks.factory.ConnectionManagerFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
<!-- ###### LIVE JDBC Data Source ###### -->
<bean id="liveDataSource"
class="org.jencks.factory.ConnectionFactoryFactoryBean">
<property name="managedConnectionFactory"
ref="liveJDBCManagedConnectionFactory" />
<property name="connectionManager" ref="liveConnectionManager" />
</bean>
rabueckers wrote:
Does anyone have a working Spring config. for Jencks2.0 that contains more than on database/data source.
Environment: Eclipse\Hibernate3\Spring\Jencks2.0\Oracle10g\Junit
I'm having a few issues with my config...
While executing Junit tests it doesn't appear to recognize the initial transaction. Remember, I have 2 data sources, and for some reason the initial transaction loads with a connection to dataSource1, even though the JUnit I'm running goes against hibernate objects from dataSource2. What happens at that point is the transaction rolls back because the underlying "table or view doesn't exist". And then the next JUnit test method executes fine and connects to the correct datasource(dataSource2).
Here is a snippet of my Spring config...
<!-- ###### Transaction manager ###### -->
<bean id="transactionManager"
class="org.jencks.factory.TransactionManagerFactoryBean"/>
<!-- ###### JTA Transaction manager ###### -->
<bean id="jtaTransactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="userTransaction" ref="transactionManager" />
</bean>
<!-- ###### Connection Manager ###### -->
<bean id="connectionManager"
class="org.jencks.factory.ConnectionManagerFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
<!-- ###### LIVE JDBC Managed Connection Factory ###### -->
<bean id="liveJDBCManagedConnectionFactory"
class="org.jencks.tranql.DataSourceMCF">
<property name="driverName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@xxx:1521:dgr11" />
<property name="user" value="xxx" />
<property name="password" value="zzz" />
</bean>
<!-- ###### CONFIG JDBC Managed Connection Factory ###### -->
<bean id="configJDBCManagedConnectionFactory"
class="org.jencks.tranql.DataSourceMCF">
<property name="driverName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@xxx:1521:dgc11" />
<property name="user" value="xxx" />
<property name="password" value="zzz" />
</bean>
<!-- ###### LIVE JDBC Data Source ###### -->
<bean id="liveDataSource"
class="org.jencks.factory.ConnectionFactoryFactoryBean">
<property name="managedConnectionFactory"
ref="liveJDBCManagedConnectionFactory" />
<property name="connectionManager" ref="connectionManager" />
</bean>
<!-- ###### CONFIG JDBC Data Source ###### -->
<bean id="configDataSource"
class="org.jencks.factory.ConnectionFactoryFactoryBean">
<property name="managedConnectionFactory"
ref="configJDBCManagedConnectionFactory" />
<property name="connectionManager" ref="connectionManager" />
</bean>
<!-- ###### LIVE Hibernate SessionFactory ###### -->
<bean id="sessionFactory"
class="com.mckesson.common.orm.hibernate.LocalSessionFactoryBean"
lazy-init="false" singleton="true">
<property name="dataSource" ref="liveDataSource" />
<property name="mappingLocations">
<list>
<value>classpath*:/com/mckesson/common/eom/**/*.hbm.xml</value>
<value>classpath*:/com/mckesson/documentation/hibernate/*.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.connection.pool_size">3</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.logging">TRACE</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
</props>
</property>
<property name="jtaTransactionManager">
<bean factory-bean="jtaTransactionManager" factory-method="getTransactionManager"/>
</property>
</bean>
<!-- ###### CONFIG Hibernate SessionFactory ###### -->
<bean id="configSessionFactory"
class="com.mckesson.common.orm.hibernate.LocalSessionFactoryBean"
lazy-init="false" singleton="true">
<property name="dataSource" ref="configDataSource" />
<property name="mappingLocations">
<list>
<value>
classpath*:/com/mckesson/documentation/config/hibernate/*.hbm.xml
</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.connection.pool_size">3</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.logging">TRACE</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
</props>
</property>
<property name="jtaTransactionManager">
<bean factory-bean="jtaTransactionManager" factory-method="getTransactionManager"/>
</property>
</bean>
Any help would be greatly appreciated as we are delivering our code very soon!
Thanks again!
Bob