File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes 2 config.xml file in hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply locked New topic

2 config.xml file in hibernate

yogesh kalaskar

Joined: Jan 24, 2007
Posts: 6
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"

<hibernate-mapping package="com.sys.objectmodel">
<class name="Service" table="Service">
<id name="serviceId" type="long" column="ServiceId" >
<generator class="assigned"/>
<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"

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

<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE hibernate-configuration PUBLIC

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




<property name="hibernate.connection.driver_class"></property>

<property name="hibernate.connection.url">jdbc:mysql://</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"/>

As you can see Product.hbm.xml is not present in hb1.cfg.xml
David Newton

Joined: Sep 29, 2008
Posts: 12617

This is a Hibernate question and has nothing to do with Struts.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Please do not duplicate post. I am closing this thread.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: 2 config.xml file in hibernate
It's not a secret anymore!