I have more than 10 .hbm files and I would like to mention the global properties in a global mapping file instead giving in each mapping file.
I have referred the section
3.3.4 Handling global metadata in Hibernate Book. Created a mapping file called global.hbm.xml.
Code:
<hibernate-mapping
schema="AUCTION"
default-lazy="false"
default-access="field"
auto-import="false"
package="com.myapp.model">
</hibernate-mapping>
I have two more mappings like this:
Employee.hbm.xmlCode:
<hibernate-mapping>
<class name="Employee" table="EMPLOYEE">
.....
</class>
</<hibernate-mapping>
Code:
[b]Employment.hbm.xml[/b]
<hibernate-mapping>
<class name="Employment" table="EMPLOYMENT">
.....
</class>
</<hibernate-mapping>
Here what I mentioned in
hibernate.cfg.xml file
Code:
<hibernate-configuration>
.....
<mapping resource="com/myapp/model/global.xml">
<mapping resource="com/myapp/model/Employee.xml">
<mapping resource="com/myapp/model/Employment.xml">
</hibernate-configuration>
When I export the schema, it gives the error message:
Code:
org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/myapp/model/global.hbm.xml
A class were not found in the classpath of the Ant task.
Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.
My other alternative is to mention all global properties in each hibernate mapping, which is redundant.
How can I maintain a global mapping file and make sure the properties are applied to other mappings.
Hibernate version: 3.2.6