Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Application Configuration for Hibernate and 2 Databases
...
<bean id="dataSourceMySql" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://mysql.host:3306/test" />
<property name="username" value="mysql_user" />
<property name="password" value="mysql_pass" />
</bean>
<bean id="dataSourceOracle" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@oracle.host:1521:INTL" />
<property name="username" value="oracle_user" />
<property name="password" value="oracle_pass" />
</bean>
<bean id="sessionFactoryMySql" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSourceMySql" />
<property name="packagesToScan" value="com.test.domain.mysql" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
</props>
</property>
</bean>
<bean id="sessionFactoryOracle" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSourceOracle" />
<property name="packagesToScan" value="com.test.domain.oracle" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
</props>
</property>
</bean>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.