You should have separate session factory and data source configuration for each of your DBS and you could refer to the correct one e.g by data source name.
That means if you have 3 remote databases then ideally you should have 3 sessionFacories and datasources.
Example:
hibernate-first.cfg.xml - same as you had
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.SetBigStringTryClob">true</property>
<property name="hibernate.jdbc.batch_size">0</property>
<!-- Here commes the entities mapped to tables in the FIRST database -->
<mapping class="com.yourpackage.EntityOftheFirstDatabase" />
</session-factory>
hibernate-second.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.connection.SetBigStringTryClob">true</property>
<property name="hibernate.jdbc.batch_size">0</property>
<!-- Here commes the entities mapped to tables in the SECOND database -->
<mapping class="com.yourpackage.EntityOftheSecondDatabase" />
</session-factory>
Now lets configure the session factories in spring:
<!-- Hibernate SessionFactory for the FIRST database -->
<bean id="sessionFactoryForTheFirstDatabase" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSourceForTheFirstDatabase" />
<property name="configLocation" value="classpath:hibernate-first.cfg.xml" />
</bean>
<!-- Hibernate SessionFactory for the SECOND database -->
<bean id="sessionFactoryForTheSecondDatabase" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSourceForTheSecondDatabase" />
<property name="configLocation" value="classpath:hibernate-second.cfg.xml" />
</bean>
DataSources
<bean id="dataSourceForTheFirstDatabase" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="your specific" />
<property name="url" value="${database.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>
The second datasource is the very same just point it to the second database. If you want to configure the Tx management than you need two transaction managers for your databses:
<bean id="firstDbServiceProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<description>Transaction boundaries are mapped to service layer</description>
<property name="proxyTargetClass" value="false" />
<property name="beanNames">
<list>
<value>ServicesMangingoperationsAboveYourFirstDatabase1</value>
<value>ServicesMangingoperationsAboveYourFirstDatabase2</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>FirstDbTxInterceptor</value>
</list>
</property>
</bean>
If you want to have single transaction accross multiple databases it is also possible, just dunno whether you need it or not! Hope it was enough clear for you. I know that there are more fancy ways to define the TX manager and the spring stuff mainly if you are using the newest one, i would sugges you to give it a try as I described and after that you could tweak it - google is your friend :)