-->
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: Mix inheritance strategies?
PostPosted: Thu Mar 23, 2006 12:52 pm 
Newbie

Joined: Mon Jan 30, 2006 2:26 pm
Posts: 9
Location: Germany
Hi all,

is it possible to mix inheritance strategies?
My concrete example is:

ContentItem <-- FileItem <-- ImageItem

These three classes are supposed to be base classes for other (maybe more specialized classes) in a CMS.

Now, for performance sake these three classes would be part of a table per class hierarchy scenario, putting all properties into fields of one table.
This table would be part of the CMS Core.

Others might want to derive from one of these three classes and add additional properties etc. Could this then be solved using joined subclasses?

For example, taken the FileItem class from above, in a CMS-module I want a XslFileItem, derived from FileItem - could this be done?

Thanks for any help!


Top
 Profile  
 
 Post subject: Re: Mix inheritance strategies?
PostPosted: Thu Mar 23, 2006 3:59 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
I don't have a link handy, but no, I don't believe this is supported by NHibernate 1.x. The feature was added at Hibernate 3.x, but NH is a port of the 2.1.x version. Nor are there plans to add it before the Great Porting Project (of H3 to NH).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 24, 2006 4:00 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
We rolled our own framework to do this. We keep a type registry (dictionary), keyed by the entity's unqualified class name. Each registry entry is itself an inheritance list; the last item in the list is the type actually instantiated. Each type in a given inheritance list for an entity must have the same unqualified class name, but uses a different namespace (and normally a different assembly). Our implementation of NHibernate.IInterceptor.Instantiate uses the type registry to instantiate the correct type. Also, the hbm.xml file for the last type in each inheritance list is added to the NHibernate configuration. This way, existing HQL queries (that don't specify namespaces) work without modification, automagically returning the correct subtypes.

Does this approach solve your problem?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 2:35 am 
Newbie

Joined: Mon Jan 30, 2006 2:26 pm
Posts: 9
Location: Germany
Thanks for your help.

I am not sure if the mentioned "type registry" would work with what I wanted to do.

If mixing won't work, I guess I will have to stick with "joined subclass" approach.


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.