Announcement Announcement Module
Collapse
No announcement yet.
OJB multiple database support Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OJB multiple database support

    Hi,

    i've got a question regarding Spring's OJB support. i've an app which accesses 2 databases. OJB supports multiple dbs natively. Now using Spring i've the following configuration:

    <!-- Default transaction manager for default database as defined in jdbc-connection-descriptor -->
    <bean id="transactionManagerDef" class="org.springframework.orm.ojb.PersistenceBrok erTransactionManager"/>

    <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean" abstract="true">
    <property name="transactionManager"><ref bean="transactionManagerDef"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>

    <bean id="ojbDaoDef" parent="baseTransactionProxy">
    <property name="target">
    <ref local="ojbDaoImplDef"/>
    </property>
    </bean>

    <bean id="ojbDaoImplDef" class="at.ekalkulator.db.ojb.SpringPersistenceBrok erDao"/>

    <!-- transaction manager for other database as defined in jdbc-connection-descriptor -->
    <bean id="transactionManagerOther" class="org.springframework.orm.ojb.PersistenceBrok erTransactionManager">
    <property name="jcdAlias"><value>OtherDB</value></property>
    </bean>

    <bean id="ojbDaoOther" parent="baseTransactionProxy">
    <property name="transactionManager"><ref bean="transactionManagerOther"/></property>
    <property name="target">
    <ref local="ojbDaoImplOther"/>
    </property>
    </bean>

    <bean id="ojbDaoImplOther" class="at.ekalkulator.db.ojb.SpringPersistenceBrok erDao">
    <property name="jcdAlias"><value>OtherDB</value></property>
    </bean>

    The configuration has a lot of redundancy due to the fact that the jcdAlias property is not propagated from the Transaction Manager to the DAO class. With adding more databases to my app Spring's configuration becomes very tedious.
    Is there a more elegant solution to my problem?

    thx,

    Liang
Working...
X