Trung Nguyen

Greenhorn
+ Follow
since Jun 08, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Trung Nguyen

Hello All, I am a newbie to Hibernate a month ago and very excited to apply the latest&greatest to my new project which I have to access to the legacy database. Been reading lots of forums and still not be able to find the solution to my mapping issues. Exciting still and hopeful still that helps are coming. Here is my mapping issues.

TableA
- column 1
- column 2
- column 3
.....more columns
column 1,2 are the primary keys

TableB
- column 1
- column 2
.... more columns
column 1,2 are the primary keys

TableA is 1-2-Many association TableB

To retrieve TableB records, I have to use the TableA(column 3)to map to TableB(column1)(no mapping needed for TableB(column 2) for record retrieval, but for record insertion, I do).

How should I go about mapping the TableA,TableB?

After nights(3) of sleepless, I am thinking about...no mapping for TableA/TableB at all, I will have to query the TableB as a separate step, meaning, after retrieval the TableA record, I will use the TableA(column 3) to query the TableB. Is this an acceptable solution?

Here is my not-working mapping hbm.xml files:
********************************************
<class name="User" table="A"
dynamic-update="true" optimistic-lock="version">
<meta attribute="class-description">
Represents a User for the WASD web site.
@author trungu
</meta>
<meta attribute="implement-equals">true</meta>
<meta attribute="implement-tostring">true</meta>
<composite-id name="id" class="ClassA">
<key-property name="acctId" type="string" column="1"
length="10">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
<key-property name="userId" type="string" column="2"
length="16">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
</composite-id>
<property name="userClass" column="3" type="string"
length="5" unique="true"/>

<set name="userFunction" inverse="true">
<key column="1"/>
<one-to-many class="ClassB"/>
</set>
*******************************************************
<class name="UserFunction" table="B" dynamic-update="true"
optimistic-lock="version">
<meta attribute="class-description">
Represents a UserFunction for the WASD web site.
@author trungu
</meta>
<meta attribute="implement-equals">true</meta>
<meta attribute="implement-tostring">true</meta>
<composite-id name="id" class="ClassB">
<key-property name="usrClassId" type="string" column="1"
length="5">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
<key-property name="functionId" type="string" column="2"
length="3">
<meta attribute="use-in-equals">true</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
</composite-id>