-->
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.  [ 3 posts ] 
Author Message
 Post subject: Modular mapping files
PostPosted: Tue Aug 31, 2004 4:25 pm 
Newbie

Joined: Tue Aug 31, 2004 4:11 pm
Posts: 3
Hibernate version: 2.1.5

From Hibernate Doc,
" 5.4. Modular mapping files
It is possible to define subclass and joined-subclass mappings in seperate mapping documents, directly beneath hibernate-mapping. This allows you to extend a class hierachy just by adding a new mapping file. You must specify an extends attribute in the subclass mapping, naming a previously mapped superclass. Use of this feature makes the ordering of the mapping documents important!
<hibernate-mapping>
<subclass name="eg.subclass.DomesticCat" extends="eg.TheCat" discriminator-value="D">
<property name="name" type="string"/>
</subclass>
</hibernate-mapping>"

Can someone tell me how I can control the ordering of the mapping? I tried to specify the order in the the build.xml file:

<hbm2java output="${build.gen-src.dir}">
<fileset dir="${build.gen-src.dir}">
<include name="**/TheCat.hbm.xml"/>
<include name="**/DomesticCat.hbm.xml"/>
</fileset>
</hbm2java>

but when I ran it with Ant, I am getting the exception:

net.sf.hibernate.MappingException: Cannot extend unmapped class eg.TheCat
...

Thanks


Top
 Profile  
 
 Post subject: Re: Modular mapping files
PostPosted: Wed Sep 01, 2004 6:38 pm 
Newbie

Joined: Tue Aug 31, 2004 4:11 pm
Posts: 3
yinl wrote:
Hibernate version: 2.1.5

From Hibernate Doc,
" 5.4. Modular mapping files
It is possible to define subclass and joined-subclass mappings in seperate mapping documents, directly beneath hibernate-mapping. This allows you to extend a class hierachy just by adding a new mapping file. You must specify an extends attribute in the subclass mapping, naming a previously mapped superclass. Use of this feature makes the ordering of the mapping documents important!
<hibernate-mapping>
<subclass name="eg.subclass.DomesticCat" extends="eg.TheCat" discriminator-value="D">
<property name="name" type="string"/>
</subclass>
</hibernate-mapping>"

Can someone tell me how I can control the ordering of the mapping? I tried to specify the order in the the build.xml file:

<hbm2java output="${build.gen-src.dir}">
<fileset dir="${build.gen-src.dir}">
<include name="**/TheCat.hbm.xml"/>
<include name="**/DomesticCat.hbm.xml"/>
</fileset>
</hbm2java>

but when I ran it with Ant, I am getting the exception:

net.sf.hibernate.MappingException: Cannot extend unmapped class eg.TheCat
...

Thanks


Top
 Profile  
 
 Post subject: Re: Modular mapping files
PostPosted: Wed Sep 01, 2004 6:41 pm 
Newbie

Joined: Tue Aug 31, 2004 4:11 pm
Posts: 3
Figured it out. You need to put the files in seperated <fileset>.


<hbm2java output="${build.gen-src.dir}">
<fileset dir="${build.gen-src.dir}">
<include name="**/TheCat.hbm.xml"/>
</fileset>
<fileset dir="${build.gen-src.dir}">
<include name="**/DomesticCat.hbm.xml"/>
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.