Hi,
I need to map multiple clesses into one database table.The common
table (TABLE1) is shared by class ClassB and SubclassA (subclass of
ClassA) mapped by <union-subcless>. Mapping file looks like in the
following example:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >
<class name="NhMappingTest.ClassB, NhMappingTest" table="TABLE1" >
<id name="Id" >
<column name="id" sql-type="Int32"/>
<generator class="identity" />
</id>
<property name="Name" type="String" column="name" />
</class>
<class name="NhMappingTest.ClassA, NhMappingTest" abstract="true" >
<id name="Id" >
<column name="id" sql-type="Int32"/>
<generator class="identity" />
</id>
<property name="Name" type="String" column="name" />
<union-subclass name="NhMappingTest.SubclassA, NhMappingTest"
table="TABLE1" />
</class>
</hibernate-mapping>
When NH try to create mappings, its raise the following exception:
NHibernate.MappingException {"Could not compile the mapping document:
NhMappingTest.Mappings.hbm.xml"} - inner exception:
NHibernate.DuplicateMappingException {"Duplicate table mapping
TABLE1"}.
But when we change order of mapping definitions in file, like this:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" >
<class name="NhMappingTest.ClassA, NhMappingTest" abstract="true" >
<id name="Id" >
<column name="id" sql-type="Int32"/>
<generator class="identity" />
</id>
<property name="Name" type="String" column="name" />
<union-subclass name="NhMappingTest.SubclassA, NhMappingTest"
table="TABLE1" />
</class>
<class name="NhMappingTest.ClassB, NhMappingTest" table="TABLE1" >
<id name="Id" >
<column name="id" sql-type="Int32"/>
<generator class="identity" />
</id>
<property name="Name" type="String" column="name" />
</class>
</hibernate-mapping>
everything is ok and mappings are build correctly.
My question is about the presented behaviour of NH, it's correct ("by
desing") or it's a bug?
--
Piotr Jakóbczyk
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---