i use 3 DB in my project with weblogic, struts2 and hibernate
i have created a dynamic factory, 3 .cfg.xml file and 3 datasource, when i want to change db i call the factory with a param and i get the right connection
the problem is that there are some identical table in the 3 DB
how can i map the bean?
if i use 2 different .cfg.xml for the same bean it creates an error; i have created another .cfg.xml file and i use it to map all my bean only in that file, it seems to work
so i have 3 .cfg.xml with a code like this:
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.Oracle10gDialect
</property>
<property name="jndi.class">
weblogic.jndi.WLInitialContextFactory
</property>
<property name="connection.datasource">ihjDATA</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
and another one with all the beans:
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.Oracle10gDialect
</property>
<mapping class="mypackage.Bean1" />
<mapping class="mypackage.Bean2" />
<mapping class="mypackage.Bean3" />
...
...
</session-factory>
</hibernate-configuration>
is the right solution? thanks and sorry for my bad english