Mapping documents:
Good Morning,
I have come across a road block and can't seem to find the best code structure.
I have a MS Access database that has 4 tables. Here is the relationship between the tables.
Tables 1,2,3 have the common primary key (Let's say Key 1).
Table 2 and 3 have an additional primary key (Let's say Key 2)
Now the table 4 has 1 primary key (Key 2), which is common with Table 2,3.
Table 1 and Table 4 are parents.
Currently i am using one-to-many relationship.
Can someone help me with the correct code?
Really appreciated. Below i have included my code for Table 1, 2, 3, 4
Table 1 - Requests
Table 2 - RequestFields
Table 3 - RequestOverrideFields
Table 4 - Fields
Table 1 - Requests
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MuniDataAccess" namespace="MuniDataAccess">
<class name="MuniDataAccess.Bloomberg.Request" table="Requests">
<meta attribute="scope-get">public virtual</meta>
<id name="RequestID" column="RequestID" type="Int32">
<generator class="assigned"/>
</id>
<property name="RequestName" column="RequestName" type="String"/>
<set name="ReqFields" lazy="true">
<key column="RequestID" />
<one-to-many class="MuniDataAccess.Bloomberg.ReqField"/>
</set>
<set name="ReqOvrFields" lazy="true">
<key column="RequestID" />
<one-to-many class="MuniDataAccess.Bloomberg.ReqOvrFld"/>
</set>
</class>
</hibernate-mapping>
----------------------------------
Table 2 - RequestFields
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MuniDataAccess" namespace="MuniDataAccess">
<class name="MuniDataAccess.Bloomberg.ReqField" table="RequestFields">
<meta attribute="scope-get">public virtual</meta>
<id name="RequestID" column="RequestID" type="Int32">
<generator class="assigned"/>
</id>
<property name="FieldID" column="FieldID" type="Int32"/>
<!--<one-to-one name="Field" class="MuniDataAccess.Bloomberg.Fld"/>-->
</class>
</hibernate-mapping>
-----------------------------------
Table 3 - RequestOverrideFields
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MuniDataAccess" namespace="MuniDataAccess">
<class name="MuniDataAccess.Bloomberg.ReqOvrFld" table="RequestOverrideFields">
<meta attribute="scope-get">public virtual</meta>
<id name="RequestID" column="RequestID" type="Int32">
<generator class="assigned"/>
</id>
<property name="FieldID" column="FieldID" type="Int32" />
<property name="Defaultval" column="DefaultVal" type="Double"/>
</class>
</hibernate-mapping>
-----------------------------------
Table 4 - Fields
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MuniDataAccess" namespace="MuniDataAccess">
<class name="MuniDataAccess.Bloomberg.Fld" table="Fields">
<meta attribute="scope-get">public virtual</meta>
<id name="FieldID" column="FieldID" type="Int32">
<generator class="assigned"/>
</id>
<property name="FieldMneumonic" column="FieldMneumonic" type="string"/>
</class>
</hibernate-mapping>
-----------------------------------