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