<mapping>
<jcs-class-cache>
<jcs-collection-cache>
<collection-cache>
Configuration configurate = new Configuration().addURL(Configuration.class.getResource ("/Book.hbm.xml"));
Configuration config = new Configuration().addFile("/Cat.hbm.xml");
SessionFactory mysqlFactory = new Configuration().configure("/mysql.cfg.xml").buildSessionFactory();
SessionFactory sqlserverFactory = new Configuration().configure("sqlserver.cfg.xml ").buildSessionFactory();
<beans>
<bean id="mysqlDS" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="url">
<value>jdbc:mysql://localhost:3306/test</value>
</property>
<property name="driverClassName">
<value>org.gjt.mm.mysql.Driver</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="passWord">
<value>123</value>
</property>
</bean>
<bean id="mysqlFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="mysqlDS"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>test.hbm.xml</value>
</list>
</property>
</bean>
<bean id="sqlserverDS" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="url">
<value>jdbc:odbc:test</value>
</property>
<property name="driverClassName">
<value>sun.jdbc.odbc.JdbcOdbcDriver</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>123</value>
</property>
</bean>
<bean id="sqlserverFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="sqlserverDS"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>test.hbm.xml</value>
</list>
</property>
</bean>
.......
</beans>
新闻热点
疑难解答