Hello,
i have a problem concering the order in which update / insert statements
on different tables are executed by hibernate. What i do not understand is
why hibernate executes statements for insert/update in a different
order when i change the fetchmode of my criteria query !!
(hibernate 3.0.5)
The first criteria is :
Code:
Criteria crit = session.createCriteria( AwGeschaeft.class )
.setFetchMode( "SetOfAwBesicherung", FetchMode.SELECT );
List g = crit.list();
performs the updates in the following order (first AW_GESCHAEFT table,
then AW_BESICHERUNG table) :
Code:
Hibernate: update BA2_DEV.AW_GESCHAEFT set MARKTWERT=?, ART=? where BANK_ID=? and STICHTAG=? and LAUFKENNUNG_NR=? and KONTO_NR=? and KONTO_NR_SUB=?
Hibernate: update BA2_DEV.AW_BESICHERUNG set ABLAUFDATUM=? where BANK_ID=? and STICHTAG=? and LAUFKENNUNG_NR=? and KONTO_NR=? and KONTO_NR_SUB=? and SICHERUNGS_ID=?
The second criteria is (only different fetch mode) :
Code:
Criteria crit = session.createCriteria( AwGeschaeft.class )
.setFetchMode( "SetOfAwBesicherung", FetchMode.JOIN );
List g = crit.list();
performs the following updates (different order of tables, first
the AW_BESICHERUNG table then the AW_GESCHAEFT table) :
Code:
Hibernate: update BA2_DEV.AW_BESICHERUNG set ABLAUFDATUM=? where BANK_ID=? and STICHTAG=? and LAUFKENNUNG_NR=? and KONTO_NR=? and KONTO_NR_SUB=? and SICHERUNGS_ID=?
Hibernate: update BA2_DEV.AW_GESCHAEFT set MARKTWERT=?, ART=? where BANK_ID=? and STICHTAG=? and LAUFKENNUNG_NR=? and KONTO_NR=? and KONTO_NR_SUB=?
why does hibernate perform the statement in a different order on the
tables ? is this a bug ? is there a way to influence the table order ?
regards,
Andreas
Hibernate version: 3.0.5
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="AwGeschaeft" table="AW_GESCHAEFT" schema="BA2_DEV" lazy="false">
<composite-id name="id" class="AwGeschaeftId">
<key-property name="BankId" type="java.lang.Short">
<column name="BANK_ID" scale="3" precision="0" not-null="true" sql-type="NUMBER" />
</key-property>
<key-property name="Stichtag" type="java.lang.Integer">
<column name="STICHTAG" scale="8" precision="0" not-null="true" sql-type="NUMBER" />
</key-property>
<key-property name="LaufkennungNr" type="java.lang.Byte">
<column name="LAUFKENNUNG_NR" scale="2" 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>
<key-property name="KontoNrSub" type="java.lang.Long">
<column name="KONTO_NR_SUB" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
</key-property>
</composite-id>
<property name="Marktwert" type="java.math.BigDecimal">
<column name="MARKTWERT" scale="20" precision="4" not-null="false" sql-type="NUMBER" />
</property>
<property name="Art" type="java.lang.Long">
<column name="ART" scale="10" precision="0" not-null="false" sql-type="NUMBER" />
</property>
<set name="SetOfAwBesicherung" fetch="join"
inverse="true">
<key>
<column name="BANK_ID" scale="3" precision="0" not-null="false" />
<column name="STICHTAG" scale="8" precision="0" not-null="false" />
<column name="LAUFKENNUNG_NR" scale="2" precision="0" not-null="false" />
<column name="KONTO_NR" scale="15" precision="0" not-null="false" />
<column name="KONTO_NR_SUB" scale="15" precision="0" not-null="false" />
</key>
<one-to-many class="AwBesicherung" />
</set>
</class>
</hibernate-mapping>
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="AwBesicherung" table="AW_BESICHERUNG" schema="BA2_DEV" lazy="false">
<composite-id name="id" class="AwBesicherungId">
<key-property name="BankId" type="java.lang.Short">
<column name="BANK_ID" scale="3" precision="0" not-null="true" sql-type="NUMBER" />
</key-property>
<key-property name="Stichtag" type="java.lang.Integer">
<column name="STICHTAG" scale="8" precision="0" not-null="true" sql-type="NUMBER" />
</key-property>
<key-property name="LaufkennungNr" type="java.lang.Byte">
<column name="LAUFKENNUNG_NR" scale="2" 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>
<key-property name="KontoNrSub" type="java.lang.Long">
<column name="KONTO_NR_SUB" scale="15" precision="0" not-null="true" sql-type="NUMBER" />
</key-property>
<key-property name="SicherungsId" type="java.lang.String">
<column name="SICHERUNGS_ID" scale="100" precision="0" not-null="true" sql-type="VARCHAR2" />
</key-property>
</composite-id>
<many-to-one name="AwGeschaeft" class="AwGeschaeft" update="false" insert="false"
>
<column name="BANK_ID" scale="3" precision="0" not-null="false" />
<column name="STICHTAG" scale="8" precision="0" not-null="false" />
<column name="LAUFKENNUNG_NR" scale="2" precision="0" not-null="false" />
<column name="KONTO_NR" scale="15" precision="0" not-null="false" />
<column name="KONTO_NR_SUB" scale="15" precision="0" not-null="false" />
</many-to-one>
<property name="Ablaufdatum" type="java.util.Date">
<column name="ABLAUFDATUM" scale="7" precision="0" not-null="false" sql-type="DATE" />
</property>
</class>
</hibernate-mapping>