-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: 3 DB with same table
PostPosted: Fri Dec 10, 2010 5:53 am 
Newbie

Joined: Fri Dec 10, 2010 5:40 am
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.