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: Mapping associations in class hierarchy
PostPosted: Thu Oct 22, 2009 5:06 am 
Newbie

Joined: Tue Oct 20, 2009 8:30 am
Posts: 1
Hey. I have created an application in C#.net 3.5, using NHibernate!

To expose my problem, i have simplified the implemented domain model -> the following small class hierarchy should be enough to point out my problem!

BaseClass
Object : BaseClass
ObjectVariant : BaseClass
Document : Object
DocumentVariant : ObjectVariant
Document2 : Object
DocumentVariant2 : ObjectVariant

The class "Object" contains a collection of objects of type "ObjectVariant".
(
Code:
private ICollection<ObjectVariant> variants;
)

The persistent classes are "Object", "ObjectVariant", "Document", "Document2", "DocumentVariant", "DocumentVariant2"!
Therefore there are six tables in the database equivalent to these six classes!
And there are six mapping files, whereas the four classes starting with "Document" extend their base class!

Now I've following requirements regarding querying the database with the ICriteria API!
- query for "Object" including "ObjectVariant";
estimated result: all Objects, Documents and Documents2 including their Variants!
estimated tables in sql: all six tables!
actual: as estimated

- query for "Document" including "DocumentVariant";
estimated result: all Documents with it's DocumentVariants
estimated tables: Object, ObjectVariant, Document, DocumentVariant
actually used tables: Object, ObjectVariant, Document, DocumentVariant + DocumentVariant2
reason: the "bag variants" is mapped in the mapping file for the class "Object" -> therefore NHibernate joins all possible Variants
problem: if I would map the "bag variants" in the derived class mappings and then query the base class including variants, the aliases for the different DocumentVariant tables would be the same in the sql query --> ADOException.

The outcome of this is following question: "Is it possible to 'override' the bag 'variants' in the derived mappings?"
Or is there any other way to achieve my requirements?

I would like to post a simple application including my problem, but it seems that this is not possible in this forum!

If someone can help me or is interessted in this problem, I could mail the small demo application!

Thanks in advance!


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.