Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

2 config.xml file in hibernate

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I want to keep 2 config files as i have 2 database systems to work with.

The classes of mapping files in hb1.cfg.xml are referring to the classes in hb2.cfg.xml as they have many to one relationship between them.

But in session factory i can configure only one xx.cfg.xml file. It results into org.hibernate.MappingException: An association from the table XXX refers to an unmapped class: YYY.

Any idea how to resolve it.

------------------------------------------
Mapping file in hb1.cfg.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.sys.objectmodel">
<class name="Service" table="Service">
<id name="serviceId" type="long" column="ServiceId" >
<generator class="assigned"/>
</id>
<property name="serviceDescription" column="ServiceDescription" />
<property name="price" column="Price" />

<many-to-one name="product" class="Product" column="ProductId"/>

<set name="userSet" table="User_Service">
<key column="ServiceId"/>
<many-to-many column="UserId"
class="User"/>
</set>

<set name="ciResourceSet" table="ServiceUtilizes">
<key column="ServiceId"/>
<many-to-many column="ResourceId"
class="CIResource"/>
</set>

</class>
</hibernate-mapping>
-----------------------------------------
hb1.cfg.xml
<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">



<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>

<property name="hibernate.connection.url">jdbc:mysql://10.25.121.163:3306/cmdb_2</property>

<property name="hibernate.connection.username">root</property>

<property name="hibernate.connection.password">root</property>

<property name="hibernate.connection.pool_size">10</property>

<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<mapping resource="hbm\Service.hbm.xml"/>
</session-factory>
</hibernate-configuration>


As you can see Product.hbm.xml is not present in hb1.cfg.xml
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This is a Hibernate question and has nothing to do with Struts.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not duplicate post. I am closing this thread.

Mark
 
    Bookmark Topic Watch Topic
  • New Topic