I have two tables DTNAME (holds addresses), DTNAMELOG (holds a list of previous company names and the date and time they were changed). The DTNAME (address) key is a partial key in the DTNAMELOG (address history) file. DTNAME's key (MGROUP, MID) references the partial key (MLGROUP, MLID) in DTNAMELOG. So I want the Dtname class to contain a set of Dtnamelog's (the history) AND Dtnamelog to have reference to the current instance of Dtname.
How do I modify the mappings of Dtnamelog and Dtname to reflect this?
I started by adding this to Dtname: <set name="history" fetch="join" inverse="true"> <key> <column name="group"/> <column name="id"/> </key> <one-to-many class="Dtnamelog"/> </set>
and this to Dtnamelog: <many-to-one name="currentName" class="Dtname"> <column name="group"/> <column name="id"/> </many-to-one>
But the examples I've seen have named attributes the same as the column names...
=======================Dtnamelog Mapping============================ <hibernate-mapping> <class catalog="S1027A32" name="db2.co99blh.Dtnamelog" schema="CO99BLH" table="DTNAMELOG"> <comment>ADDRESSES Change Log</comment> <composite-id class="db2.co99blh.DtnamelogId" name="id"> <key-property name="group" type="string"> <column length="4" name="MLGROUP"/> </key-property> <key-property name="id" type="string"> <column length="5" name="MLID"/> </key-property> <key-property name="logyr" type="short"> <column name="MLLOGYR" precision="4" scale="0"/> </key-property> <key-property name="logmn" type="byte"> <column name="MLLOGMN" precision="2" scale="0"/> </key-property> <key-property name="logdy" type="byte"> <column name="MLLOGDY" precision="2" scale="0"/> </key-property> <key-property name="loghr" type="byte"> <column name="MLLOGHR" precision="2" scale="0"/> </key-property> <key-property name="logmin" type="byte"> <column name="MLLOGMIN" precision="2" scale="0"/> </key-property> <key-property name="logsec" type="byte"> <column name="MLLOGSEC" precision="2" scale="0"/> </key-property> </composite-id> <property name="co" type="string"> <column length="75" name="MLCO" not-null="true"> <comment>Company</comment> </column> </property> <property name="logusr" type="string"> <column length="10" name="MLLOGUSR" not-null="true"> <comment>Change User</comment> </column> </property> </class> </hibernate-mapping>
=======================Dtname Mapping============================ <hibernate-mapping> <class catalog="S1027A32" name="db2.co99blh.Dtname" schema="CO99BLH" table="DTNAME"> <comment>Basic Addresses</comment> <composite-id class="db2.co99blh.DtnameId" name="id"> <key-property name="group" type="string"> <column length="4" name="MGROUP"/> </key-property> <key-property name="id" type="string"> <column length="5" name="MID"/> </key-property> </composite-id> <property name="name" type="string"> <column length="40" name="MNAME" not-null="true"> <comment>Name</comment> </column> </property> <property name="co" type="string"> <column length="40" name="MCO" not-null="true"> <comment>Company</comment> </column> </property> <property name="addr" type="string"> <column length="30" name="MADDR" not-null="true"> <comment>Address</comment> </column> </property> <property name="strt" type="string"> <column length="30" name="MSTRT" not-null="true"> <comment>Street</comment> </column> </property> <property name="city" type="string"> <column length="15" name="MCITY" not-null="true"> <comment>City</comment> </column> </property> <property name="prov" type="string"> <column length="15" name="MPROV" not-null="true"> <comment>Province</comment> </column> </property> <property name="cntry" type="string"> <column length="15" name="MCNTRY" not-null="true"> <comment>Country</comment> </column> </property> <property name="po1" type="string"> <column length="4" name="MPO1" not-null="true"> <comment>Post</comment> </column> </property> <property name="po2" type="string"> <column length="5" name="MPO2" not-null="true"> <comment>Code</comment> </column> </property> <property name="grtg" type="string"> <column length="40" name="MGRTG" not-null="true"> <comment>Greeting</comment> </column> </property> <property name="comm" type="string"> <column length="30" name="MCOMM" not-null="true"> <comment>Comment</comment> </column> </property> <property name="phar" type="string"> <column length="3" name="MPHAR" not-null="true"> <comment>Area Code</comment> </column> </property> <property name="phex" type="string"> <column length="3" name="MPHEX" not-null="true"> <comment>Tel Ex</comment> </column> </property> <property name="phnm" type="string"> <column length="4" name="MPHNM" not-null="true"> <comment>Tel Locl</comment> </column> </property> <property name="phext" type="string"> <column length="4" name="MPHEXT" not-null="true"> <comment>Tel Ext</comment> </column> </property> <property name="faxar" type="string"> <column length="3" name="MFAXAR" not-null="true"> <comment>Area Code</comment> </column> </property> <property name="faxex" type="string"> <column length="3" name="MFAXEX" not-null="true"> <comment>FAX Ex</comment> </column> </property> <property name="faxnm" type="string"> <column length="4" name="MFAXNM" not-null="true"> <comment>FAX Locl</comment> </column> </property> <property name="seq1" type="string"> <column length="20" name="MSEQ1" not-null="true"> <comment>Sequence Option 1</comment> </column> </property> <property name="seq2" type="string"> <column length="20" name="MSEQ2" not-null="true"> <comment>Sequence Option 2</comment> </column> </property> <property name="seq3" type="string"> <column length="20" name="MSEQ3" not-null="true"> <comment>Sequence Option 3</comment> </column> </property> <property name="stat" type="char"> <column length="1" name="MSTAT" not-null="true"> <comment>S T</comment> </column> </property> <property name="styr" type="short"> <column name="MSTYR" not-null="true" precision="4" scale="0"> <comment>Stat Year</comment> </column> </property> <property name="stmn" type="byte"> <column name="MSTMN" not-null="true" precision="2" scale="0"> <comment>ST MM</comment> </column> </property> <property name="stdy" type="byte"> <column name="MSTDY" not-null="true" precision="2" scale="0"> <comment>ST DD</comment> </column> </property> <property name="stusr" type="string"> <column length="10" name="MSTUSR" not-null="true"> <comment>Last User To Change Status</comment> </column> </property> <property name="cryr" type="short"> <column name="MCRYR" not-null="true" precision="4" scale="0"> <comment>Creation Year</comment> </column> </property> <property name="crmn" type="byte"> <column name="MCRMN" not-null="true" precision="2" scale="0"> <comment>Mon</comment> </column> </property> <property name="crdy" type="byte"> <column name="MCRDY" not-null="true" precision="2" scale="0"> <comment>Day</comment> </column> </property> <property name="ogrp" type="string"> <column length="4" name="MOGRP" not-null="true"> <comment>Owner Group</comment> </column> </property> <property name="oid" type="string"> <column length="5" name="MOID" not-null="true"> <comment>Owner Id</comment> </column> </property> </class> </hibernate-mapping>
|