A good white paper to read before continue using NH is here http://nhusers.googlegroups.com/web/WhitePaper_Mapping_Objects_To_Relational_Databases.pdf
2009/2/20 Fabio Maulo <[email protected]> > union-subclass is an advanced way provided by NH to implement the mapping > pattern : table-per-concrete-class > What you are looking for is the implementation of the pattern : > table-per-class-hierarchy > The tag for that is <subclass>; reference available here > http://nhforge.org/doc/nh/en/index.html#mapping-declaration-subclass > > > 2009/2/20 Piotr Jakóbczyk <[email protected]> > > >> 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 >> >> >> >> > > > -- > Fabio Maulo > -- Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
