We use multiple hibernate.cfg.xml for various environments but the list of mapping files are always the same.
Therefore I decided to create a file with all the mapping and use an xml entity to 'import' it in multiple files.
My .cfg.xml files look like this:
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd" [
<!ENTITY fileList SYSTEM "file:c:/dev/classes/hibernate-allmappings.xml">
]>
<hibernate-configuration>
<session-factory>
<!-- ************************* HIBERNATE SETTINGS *************************************************-->
... ...
<!-- ************************* DOMAIN OBJECTS ****************************************************-->
&fileList;
</session-factory>
</hibernate-configuration>
Note the usage of an xml entity (fileList). This works fine but I have to specify a full path. I would like to be able to specify to the xml parser to look for hibernate-allmappings.xml in the classpath.
Anyone done this successfully?
Thank,
Fran