Thanks for your response and
thanks for your active role in the NHibernate project first.
Problem:
I have a table with is used to store the instances of many different subclasses of a class ValueObject. When I create a new subclass (with no additional instance variables), I don't want to modify the mapping file. The subclass should be stored according to the superclass mapping.
And the discriminator value for the subclass should be assigned from NH automatically. So there is nothing new to say in the mapping file.
Idea 1 (Version 2):
In the *.hbm.xml file the use of a discriminator column is explicitly declared as usual.
But the value is not specified explicitly in <class> and <subclass> elements. Rather it is specified that the discriminator value is determined automatically by NH, e.g. :
Code:
<class>
<!-- ... -->
<discriminator
column="discriminator_column"
discriminator-auto-value="globalClassRegistry"
/>
<!-- ... -->
</class>
The value of attribute "discriminator-auto-value" is a symbolic name for the registry. In a config file the symbolic name is associated with the name of the concrete "class registry" table.
Idea 2 : The id assigned to a class is simply the next free id (e.g. using a separate hilo table for class ids).
This means the assignment of the class id-s to the classes depends on the order in which the classes are registered.
Hence the same class can have different class id-s in different data bases.
But this doesn't matter, because the mapping class -> id is read from the data base at runtime from the concrete data base (from the "class registry" table).
Regards,
Mick[/code]