-->
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: is it possible to define a relation between two join tables?
PostPosted: Mon Jun 06, 2005 7:37 am 
Newbie

Joined: Fri May 20, 2005 2:42 am
Posts: 14
Hibernate version:3.0.5

Mapping documents:
Code:
<hibernate-mapping>

  <class name="Geschaeft" table="E_GESCHAEFT" >
   
    <composite-id name="id" class="GeschaeftPK">
      <key-property name="bank" type="java.lang.Long">
        <column name="BANK_ID" scale="3" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
      <key-property name="kontoNr" type="java.lang.Long">
        <column name="KONTO_NR" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
    </composite-id>

    <set name="besicherungen" fetch="subselect" cascade="save-update" inverse="true">
      <key>
        <column name="BANK_ID" scale="3" precision="0" not-null="false" />
        <column name="KONTO_NR" scale="15" precision="0" not-null="false" />
      </key>
      <one-to-many class="Besicherung" />
    </set>

    <join table="R_GESCHAEFT_VW" optional="true" inverse="false" fetch="join">
      <key>
        <column name="BANK_ID" scale="3" precision="0" not-null="true" sql-type="NUMBER" />
        <column name="KONTO_NR" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
      </key>
      <property name="wert" type="java.lang.Double">
        <column name="wert" scale="20" precision="4" not-null="false" sql-type="NUMBER" />
      </property>
    </join>
   
  </class>
</hibernate-mapping>


<?xml version="1.0"?>
<hibernate-mapping>

  <class name="Besicherung" table="E_BESICHERUNG_VW" lazy="false">
    <composite-id name="id" class="BesicherungPK">
      <key-property name="bank" type="java.lang.Long">
        <column name="BANK_ID" scale="3" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
      <key-property name="kontoNr" type="java.lang.Long">
        <column name="KONTO_NR" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
      </key-property>
    </composite-id>

    <many-to-one name="geschaeft" class="Geschaeft" update="false" insert="false" fetch="select" lazy="true">
      <column name="BANK_ID" scale="3" precision="0" not-null="false" />
      <column name="KONTO_NR" scale="15" precision="0" not-null="false" />
    </many-to-one>

    <join table="R_BESICHERUNG_VW" optional="true" inverse="false" fetch="join">
      <key>
        <column name="TEST_BANK_ID" scale="3" precision="0" not-null="true" sql-type="NUMBER" />
        <column name="TEST_KONTO_NR" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
      </key>
      <property name="gesamtwert" type="java.lang.Double">
        <column name="GESAMTWERT" scale="20" precision="4" not-null="false" sql-type="NUMBER" />
      </property>
    </join>
   
  </class>
</hibernate-mapping>


Hi,

is it possible to define a relation between between two join tables ?
i need to define a relation between R_GESCHAEFT_VW (R_ = result data,
E_ = input data) and
R_BESICHERUNG_VW, which is exactely the same relation as
between E_GESCHAEFT AND E_BESICHERUNG_VW (one-to-many
and a many-to-one, is bidirectional). somehow i need to tell hibernate
that data needs to be inserted into R_GESCHAEFT before data is
inserted into R_BESICHERUNG (analog to E_GESCHAFT and E_BESICHERUNG).
The correct order for the E_ tables hibernate knows because
of the mapping, the order for the R_ tables hibernate does not know
because no association between the tables is defined explicitly. so is
there a way to tell hibernate that there is an association between the
two join tables.

thanxs,
Andreas


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.