Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > Re: How to map ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 3702 of 3800
Post > Topic >>

Re: How to map the table cl***** have more than one columns for its

by David Lee Lambert <davidl@[EMAIL PROTECTED] > Apr 10, 2008 at 11:49 AM

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
 




 2 Posts in Topic:
How to map the table classes have more than one columns for its
RC <raymond.chui@[EMAI  2008-04-10 08:38:21 
Re: How to map the table classes have more than one columns for
David Lee Lambert <dav  2008-04-10 11:49:33 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 4:47:13 CDT 2008.