Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to map the table classes have more than one columns for its primarykey in Hibernate?

Reply
Thread Tools

How to map the table classes have more than one columns for its primarykey in Hibernate?

 
 
RC
Guest
Posts: n/a
 
      04-10-2008
I have two existed tables, I am NOT allow to altering those tables
The 1st table (tableA) has one column for its primary key, the 2nd
table (tableB) has tow columns for its primary key. I am try to map
these two tables with Hibernate XML. Here are my XML file.

Please see ????? in tow places.

Question 1
1st ???? is <many-to-many> tag in class TableA, but <many-to-many> tag
only allows one column. How do I map it for two columns?

Question 2
2nd ????? is the <key> tag in class TableB, similar that <key> tag only
allows one column. How do I map it for two columns?

Thank Q very much in advance!

<hibernate-mapping auto-import="false"
default-lazy="true" default-access="field">

<class name="tableA" table="TABLEA" entity-name="TableA.class">
<id name="tableAId" type="string" column="TABLEAID"

access="field">
<generator class="native">
<param name="key">TABLEAID</param>
</generator>
</id>
<property name="column1" type="string" column="COLUMN1" />
<property name="column2" type="string" column="COLUMN2" />
.....
<set name="idsa" table="IDS" inverse="true">
<key column="TABLEAID" />
<many-to-many column="????" class="tableB" />
</set>
</class>

<class name="tablesB" table="TABLEB" entity-name="TableB.class">
<composite-id>
<!-- this table's primary key has two columns -->
<key-property name="tableBId1" type="string"
column="TABLEBID1" />
<key-property name="tableBId2" type="integer"
column="TABLEBID2" />
</composite-id>
<property name="column1" type="string" column="COLUMN1" />
<property name="column2" type="string" column="COLUMN2" />
....
<set name="idsb" table="IDS">
<key column="?????" />
<many-to-many column="TABLEAID" class="tableA" />
</set>
</class>
</hibernate-mapping>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to map the table classes have more than one columns for its primarykey in Hibernate? RC Java 0 04-10-2008 12:38 PM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com Java 0 03-06-2008 08:11 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C++ 0 03-05-2008 08:41 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C Programming 0 03-05-2008 03:26 AM



Advertisments