Discussion:
[Middlegen-user] many-to-many relationship middlegen for hibernate mapping files
sanjeev trivedi
2004-07-05 06:49:21 UTC
Permalink
Hi

Recently I started exploring hibernate and middlegen.

Here is simple test.

I used 3 tables say A,B and A_B (third table for
many-to-many relationship).

I found that for many-to-many relationship one
seperate class is ceated(A_B) and also for PK class
A_BPK is created.class A has one-to-many relationship
with class A_B and same is the case with class B.

What we want is that A should have Set of B as
attribute and B should have Set of A as attribute
rather than that of A_B, i.e. there should not be
third class A_B.

We are able to do this manualy by using many-to-many
relationship tag in mapping file but thru' middlegen
we are not able to achieve (middlegen gives us Set of
A_B as attribute in class A and B both and this leads
to the use of composite id and extra level of
indirection).

Any help,

thanx in advance.

Sanjeev



__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
Russell Simpkins
2004-07-05 09:50:02 UTC
Permalink
The answer should be in the build.xml file in the samples.

<!--
If you want m:n relations, they must be specified like this.
Note that tables declare in multiple locations must all have
the same value of the generate attribute.-->
<!--many2many>
<tablea generate="true" name="persons"/>
<jointable name="reservations" generate="false"/>
<tableb generate="true" name="flights"/>
</many2many-->



-----Original Message-----
From: middlegen-user-***@lists.sourceforge.net
[mailto:middlegen-user-***@lists.sourceforge.net] On Behalf Of sanjeev
trivedi
Sent: Tuesday, June 29, 2004 1:08 AM
To: middlegen-***@lists.sourceforge.net
Subject: [Middlegen-user] many-to-many relationship middlegen for
hibernate mapping files

Hi

Recently I started exploring hibernate and middlegen.

Here is simple test.

I used 3 tables say A,B and A_B (third table for
many-to-many relationship).

I found that for many-to-many relationship one
seperate class is ceated(A_B) and also for PK class
A_BPK is created.class A has one-to-many relationship
with class A_B and same is the case with class B.

What we want is that A should have Set of B as
attribute and B should have Set of A as attribute
rather than that of A_B, i.e. there should not be
third class A_B.

We are able to do this manualy by using many-to-many
relationship tag in mapping file but thru' middlegen
we are not able to achieve (middlegen gives us Set of
A_B as attribute in class A and B both and this leads
to the use of composite id and extra level of
indirection).

Any help,

thanx in advance.

Sanjeev



__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com

Loading...