-->
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.  [ 4 posts ] 
Author Message
 Post subject: Inheritance mapping problem
PostPosted: Wed May 25, 2005 3:40 am 
Hi,

i have mapped with "table per subclass" strategy two classes, so i have one mapping file with the name of the parent class.
I put the mapping file in the Reference of the parent class (i'm using VS).
The problem is : the subclass is in a different assembly file of the parent class and Nhibernate isn't able to find the mapping file.
Any solution?

Thanks
Franco Gambato


Top
  
 
 Post subject:
PostPosted: Thu May 26, 2005 4:28 am 
Regular
Regular

Joined: Tue Mar 15, 2005 12:38 pm
Posts: 73
Location: Bucharest
I sugest:

FirstAssembly: contains the parent class and it's mapping.
SecondAssembly: contains the joined-class and it-s mapping.

The, in the class where you build your cfg use something like:

Code:
cfg.AddAssembly( System.Reflection.Assembly.LoadWithPartialName( "FirstAssembly") );
cfg.AddAssembly( System.Reflection.Assembly.LoadWithPartialName( "SecondAssembly") );


Good luck,
Dragos


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 9:43 am 
Hi,

Thanks for your answer, but i haven't understood very well (i'm a newbye :().
I have only 1 mapping file with the base class name, inside this mapping file i define the subclass. So i put my xml file in the references of base class.
Have i to put the same file in the reference of the subclass? with which name?
have i to create another xml file for the subclass? in which way?
Another idea: have I to change the inheritance mapping strategy?

Thanks a lot
Franco


Top
  
 
 Post subject:
PostPosted: Fri May 27, 2005 10:13 am 
Regular
Regular

Joined: Tue Mar 15, 2005 12:38 pm
Posts: 73
Location: Bucharest
No, you can define the base class and the joned subclass in different files... so:

FirstAssembly: contains the parent class and it's mapping.

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" auto-import="true">
   <class
   name="FirstAssembly.BaseClass, FirstAssembly"
   table="BASE_CLASS">

   </class>
</hibernate-mapping>


SecondAssembly: contains the joined-class and it-s mapping.

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" auto-import="true">
   <joined-subclass
   name="SecondAssembly.JoinedClass, SecondAssembly"
   extends="FirstAssembly.BaseClass, FirstAssembly"
   table="JOINED_CLASS">

   </joined-subclass>
</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.