Hi

I'm aware of the jira NH-943 feature request and have also seem
earlier discussions here where Fabio have confirmed that there is no
way in the mapping to indicate subclassing of a component in the
current version af NHibernate.

So the question is how are you working around this in a nice way?

I have a funny situation here where I actually miss having subclassing
of components twice for the same mapping.

It's an object model that "look" like this

Document is an abstract class with the subclasses Maindocument and
Appendix. Document has a property called Metadata that again is an
abstract class with different subclasses depending of the type of
metadata and finally one of the Metadata subclasses has a property
called Casenumber that is again an abstract class with two subclasses,
because different systems have two different way of using case number:

So my first idea until I realised that I couldn't sublclass components
was to use the following pseudo mapping:

<class>
      <!-- For 'Document'. Using discriminator and two subclasses -->
      <component>
             <!-- For 'Metadata' using discriminator and n subclasses
-->
             <component>
                    <!--  For 'Casenumber' using discriminator and two
subclasses -->
             </component>
     </component>
</class>

First I then worked around by splitting up Document and Metadata and
map them with a one-to-one. It's kind of ok, even though my Document
table now have only 3 columns.

But then I came to the casenumber. Splitting out Casenumber in yet
another table just from a datamodel view seems wrong. Because I would
then basically end up with three different tables (Document, Metadata,
CaseNumber) all with one-to-one mappings between and sharing the same
id.

I saw this post 
http://colinjack.blogspot.com/2008/03/nhibernate-working-around-lack-of.html,
however couldn't get it to work. NHibernate ending up creating two
inserts to the same table with the same id, which of course failed
because the key should be unique in the database.

Any other better ways to work around this that I have just missed.


regards

Henrik Uffe Jensen

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to