-->
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.3.4 Handling global metadata
PostPosted: Wed Apr 02, 2008 2:49 pm 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
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.xml
Code:
<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


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.