These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: recursive relation - complex join
PostPosted: Tue Oct 16, 2007 10:27 am 
Newbie

Joined: Tue Oct 16, 2007 9:32 am
Posts: 2
I have the following recursive relation (E-R diagram):

soggetto-------accordo
| |
| |
|---------------|

For more flexibility I use 1-* and *-1 associations (soggetto is the same table):

soggetto--------accordo-------soggetto
1----------------*-------*----------- 1

Here my mappings:

-----SOGGETTO MAPPING--------
<hibernate-mapping>
<class
name="com.db.siscombe.database.databeans.Soggetto"
table="SOGGETTO"
schema="SISCOMBE"
>
<id
name="idSoggetto"
type="long"
column="ID_SOGGETTO"
length="22"
>
<generator class="sequence">
<param name="sequence">soggetto_seq</param>
</generator>
</id>
<property
name="codCanale"
type="string"
column="COD_CANALE"
length="9"
/>
.......

<!-- bi-directional many-to-one association to Accordo -->
<set
name="soggAccNazionales1"
lazy="true" cascade="persist"
>
<key>
<column name="ID_ACCORDO_NAZIONALE" /> <!-- a foreign key in ACCORDO referencing the primary key of this table. -->
</key>
<one-to-many class="com.db.siscombe.database.databeans.Accordo" />
</set>
<!-- bi-directional many-to-one association to Accordo -->
<set
name="soggAccNazionales2"
lazy="true" cascade="persist"
>
<key>
<column name="ID_SOGGETTO" /> <!-- a foreign key in ACCORDO referencing the primary key of this table. -->
</key>
<one-to-many class="com.db.siscombe.database.databeans.Accordo" />
</set>

-----ACCORDO MAPPING--------
<hibernate-mapping>
<class
name="com.db.siscombe.database.databeans.Accordo"
table="ACCORDO "
schema="SISCOMBE"
>
<id
name="idSoggAccNazionale"
type="long"
column="ID_SOGG_ACC_NAZIONALE"
length="22"
>
<generator class="sequence">
<param name="sequence">sogg_acc_nazionale_seq</param>
</generator>
</id>
<property
name="codIstituto"
type="string"
column="COD_ISTITUTO"
length="33"
/>
.....

<many-to-one
name="soggetto1"
class="com.db.siscombe.database.databeans.Soggetto" cascade="persist"
>
<column name="ID_ACCORDO_NAZIONALE" length="22"/>
</many-to-one>
<!-- bi-directional many-to-one association to Soggetto -->
<many-to-one
name="soggetto2"
class="com.db.siscombe.database.databeans.Soggetto" cascade="persist"
>
<column name="ID_SOGGETTO" length="22"/>
</many-to-one>

If I want to use QBE (Query by example) what is the java code to make a join soggetto---->accordo---->soggetto?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.