-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Tables with different Primary keys
PostPosted: Thu Jul 12, 2007 9:18 am 
Newbie

Joined: Thu Jul 12, 2007 9:07 am
Posts: 4
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>



-----------------------------------


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.