On Apr 10, 8:38=A0am, RC <raymond.c...@[EMAIL PROTECTED]
> wrote:
> 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.
First of all, the column "TABLEAID" can't use a "native" generator,
because it's a string column;
you probably need "assigned" (the default), or possibly need to write
your own.
Second, are you allowed to create the join table (IDS)?
To answer both of your questions, you should be able to have multiple
<column> elements in a <key> or <many-to-many> elements, instead of
one "column" attribute.
> <hibernate-mapping auto-im****t=3D"false"
> default-lazy=3D"true" default-access=3D"field">
>
> =A0 =A0 =A0<class name=3D"tableA" table=3D"TABLEA"
entity-name=3D"TableA.c=
lass">
> =A0 =A0 =A0 =A0 =A0<id name=3D"tableAId" type=3D"string"
column=3D"TABLEAI=
D"
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 =A0 =A0 =A0access=3D"field">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<generator class=3D"native">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<param name=3D"key">TABLEAID</param>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0</generator>
> =A0 =A0 =A0 =A0 =A0</id>
> =A0 =A0 =A0 =A0 =A0<property name=3D"column1" type=3D"string"
column=3D"CO=
LUMN1" />
> =A0 =A0 =A0 =A0 =A0<property name=3D"column2" type=3D"string"
column=3D"CO=
LUMN2" />
> =A0 =A0 =A0 =A0 =A0.....
> =A0 =A0 =A0 =A0 =A0<set name=3D"idsa" table=3D"IDS" inverse=3D"true">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<key column=3D"TABLEAID" />
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<many-to-many column=3D"????"
class=3D"tableB" =
/>
> =A0 =A0 =A0 =A0 =A0</set>
> =A0 =A0 =A0 </class>
>
> =A0 =A0 =A0 =A0<class name=3D"tablesB" table=3D"TABLEB"
entity-name=3D"Tab=
leB.class">
> =A0 =A0 =A0 =A0 =A0<composite-id>
> =A0 =A0 =A0 =A0 =A0<!-- this table's primary key has two columns -->
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<key-property name=3D"tableBId1"
type=3D"string=
"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 =A0 =A0 column=3D"TABLEBID1" />
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<key-property name=3D"tableBId2"
type=3D"intege=
r"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 =A0 =A0 column=3D"TABLEBID2" />
> =A0 =A0 =A0 =A0 =A0</composite-id>
> =A0 =A0 =A0 =A0 =A0<property name=3D"column1" type=3D"string"
column=3D"CO=
LUMN1" />
> =A0 =A0 =A0 =A0 =A0<property name=3D"column2" type=3D"string"
column=3D"CO=
LUMN2" />
> =A0 =A0 =A0 =A0 =A0....
> =A0 =A0 =A0 =A0 =A0<set name=3D"idsb" table=3D"IDS">
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<key column=3D"?????" />
> =A0 =A0 =A0 =A0 =A0 =A0 =A0<many-to-many column=3D"TABLEAID"
class=3D"tabl=
eA" />
> =A0 =A0 =A0 =A0 =A0</set>
> =A0 =A0 =A0 =A0</class>
> </hibernate-mapping>
--
DLL


|