Hibernate version:2.1.4
Oracle 9.2
Hi all,
I’ve got a parent-child bi-directional association where the child’s key is composite (Child ID ,Parent ID).
Everyhing works as expected whatever lazy is set to true or false as long as outer-join is not set to true.
When I add outer-join =”true”, I can save a newly instanciated parent with or without childs but when I try to read it again I get caught in an infinite loop .
I checked my hashcode() and equals() methods on each concerned class and even added log on it but these are not called in this loop. Moreover, it works perfectly without the outer- join option.
Any idea here ?
Here are my mapping files
parent :
Code:
<class
name="lm.met.vo.Contrat"
table="ccd_contrat"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="numeroContrat"
column="NUMLMD"
type="java.lang.String"
>
<generator class="lm.fwk.persistance.hibernate.StringSequenceGenerator">
<param name="sequence">CONTRAT_SEQ_ID</param>
</generator>
</id>
<property
name="idProduit"
type="java.lang.String"
update="true"
insert="true"
column="TYPCON"
/>
<property
name="libelleCommercial"
type="java.lang.String"
update="true"
insert="true"
column="LIBCON"
/>
<set
name="ctxAdh"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
sort="unsorted"
outer-join="true"
>
<key
column="NUMLMD"
/>
<one-to-many
class="lm.met.vo.ContexteAdherente"
/>
</set>
</class>
Child
Code:
<hibernate-mapping>
<class
name="lm.met.vo.ContexteAdherente"
table="ccd_adherente"
dynamic-update="false"
dynamic-insert="false"
>
<composite-id
name="key"
class="lm.met.vo.ContexteAdherenteKey"
unsaved-value="any"
>
<key-property
name="numPerAdherente"
type="java.lang.String"
column="NUMPER"
/>
<key-many-to-one
name="contrat"
class="lm.met.vo.Contrat"
column="NUMLMD"
/>
</composite-id>
<property
name="dateEffet"
type="java.util.Date"
update="true"
insert="true"
column="EFFADE"
/>
</class>
user code:Code:
Contrat c=(Contrat)session.get(Contrat.class,numeroContrat);
Debug level Hibernate log excerpt while looping : 2loopsCode:
15:20:41,274?DEBUG BatcherImpl:196 - about to open: 3 open PreparedStatements, 3 open ResultSets
15:20:41,274?DEBUG SQL:237 - select contrat0_.NUMLMD as NUMLMD2_, contrat0_.DATEFF as DATEFF2_, contrat0_.DATSIG as DATSIG2_, contrat0_.DEVISE as DEVISE2_, contrat0_.INDEXT as INDEXT2_, contrat0_.TYPCON as TYPCON2_, contrat0_.LIBCON as LIBCON2_, contrat0_.NUMLML as NUMLML2_, contrat0_.NUMPER as NUMPER2_, contrat0_.NUMGEN as NUMGEN2_, etat1_.NUMLMD as NUMLMD0_, etat1_.DATEFF as DATEFF0_, etat1_.LIBETA as LIBETA0_, etat1_.LIDCRE as LIDCRE0_, ctxadh2_.NUMPER as NUMPER__, ctxadh2_.NUMLMD as NUMLMD__, ctxadh2_.NUMPER as NUMPER1_, ctxadh2_.NUMLMD as NUMLMD1_, ctxadh2_.EFFADE as EFFADE1_, ctxadh2_.LIDCRE as LIDCRE1_, ctxadh2_.DEVISE as DEVISE1_, ctxadh2_.DATCRE as DATCRE1_ from ccd_contrat contrat0_ left outer join ccd_etat etat1_ on contrat0_.NUMLMD=etat1_.NUMLMD left outer join ccd_adherente ctxadh2_ on contrat0_.NUMLMD=ctxadh2_.NUMLMD where contrat0_.NUMLMD=?
Hibernate: select contrat0_.NUMLMD as NUMLMD2_, contrat0_.DATEFF as DATEFF2_, contrat0_.DATSIG as DATSIG2_, contrat0_.DEVISE as DEVISE2_, contrat0_.INDEXT as INDEXT2_, contrat0_.TYPCON as TYPCON2_, contrat0_.LIBCON as LIBCON2_, contrat0_.NUMLML as NUMLML2_, contrat0_.NUMPER as NUMPER2_, contrat0_.NUMGEN as NUMGEN2_, etat1_.NUMLMD as NUMLMD0_, etat1_.DATEFF as DATEFF0_, etat1_.LIBETA as LIBETA0_, etat1_.LIDCRE as LIDCRE0_, ctxadh2_.NUMPER as NUMPER__, ctxadh2_.NUMLMD as NUMLMD__, ctxadh2_.NUMPER as NUMPER1_, ctxadh2_.NUMLMD as NUMLMD1_, ctxadh2_.EFFADE as EFFADE1_, ctxadh2_.LIDCRE as LIDCRE1_, ctxadh2_.DEVISE as DEVISE1_, ctxadh2_.DATCRE as DATCRE1_ from ccd_contrat contrat0_ left outer join ccd_etat etat1_ on contrat0_.NUMLMD=etat1_.NUMLMD left outer join ccd_adherente ctxadh2_ on contrat0_.NUMLMD=ctxadh2_.NUMLMD where contrat0_.NUMLMD=?
15:20:41,274?DEBUG BatcherImpl:241 - preparing statement
15:20:41,290?DEBUG StringType:46 - binding '358 ' to parameter: 1
15:20:41,290?DEBUG Loader:197 - processing result set
15:20:41,290?DEBUG StringType:68 - returning '358 ' as column: NUMLMD0_
15:20:41,306?DEBUG StringType:68 - returning 'nico1111' as column: NUMPER1_
15:20:41,306?DEBUG StringType:68 - returning '358 ' as column: NUMLMD1_
15:20:41,306?DEBUG SessionImpl:1982 - loading [lm.met.vo.Contrat#358 ]
15:20:41,306?DEBUG SessionImpl:2079 - attempting to resolve [lm.met.vo.Contrat#358 ]
15:20:41,306?DEBUG SessionImpl:2112 - object not resolved in any cache [lm.met.vo.Contrat#358 ]
15:20:41,306?DEBUG EntityPersister:416 - Materializing entity: [lm.met.vo.Contrat#358 ]
15:20:41,306?DEBUG BatcherImpl:196 - about to open: 4 open PreparedStatements, 4 open ResultSets
15:20:41,306?DEBUG SQL:237 - select contrat0_.NUMLMD as NUMLMD2_, contrat0_.DATEFF as DATEFF2_, contrat0_.DATSIG as DATSIG2_, contrat0_.DEVISE as DEVISE2_, contrat0_.INDEXT as INDEXT2_, contrat0_.TYPCON as TYPCON2_, contrat0_.LIBCON as LIBCON2_, contrat0_.NUMLML as NUMLML2_, contrat0_.NUMPER as NUMPER2_, contrat0_.NUMGEN as NUMGEN2_, etat1_.NUMLMD as NUMLMD0_, etat1_.DATEFF as DATEFF0_, etat1_.LIBETA as LIBETA0_, etat1_.LIDCRE as LIDCRE0_, ctxadh2_.NUMPER as NUMPER__, ctxadh2_.NUMLMD as NUMLMD__, ctxadh2_.NUMPER as NUMPER1_, ctxadh2_.NUMLMD as NUMLMD1_, ctxadh2_.EFFADE as EFFADE1_, ctxadh2_.LIDCRE as LIDCRE1_, ctxadh2_.DEVISE as DEVISE1_, ctxadh2_.DATCRE as DATCRE1_ from ccd_contrat contrat0_ left outer join ccd_etat etat1_ on contrat0_.NUMLMD=etat1_.NUMLMD left outer join ccd_adherente ctxadh2_ on contrat0_.NUMLMD=ctxadh2_.NUMLMD where contrat0_.NUMLMD=?
Hibernate: select contrat0_.NUMLMD as NUMLMD2_, contrat0_.DATEFF as DATEFF2_, contrat0_.DATSIG as DATSIG2_, contrat0_.DEVISE as DEVISE2_, contrat0_.INDEXT as INDEXT2_, contrat0_.TYPCON as TYPCON2_, contrat0_.LIBCON as LIBCON2_, contrat0_.NUMLML as NUMLML2_, contrat0_.NUMPER as NUMPER2_, contrat0_.NUMGEN as NUMGEN2_, etat1_.NUMLMD as NUMLMD0_, etat1_.DATEFF as DATEFF0_, etat1_.LIBETA as LIBETA0_, etat1_.LIDCRE as LIDCRE0_, ctxadh2_.NUMPER as NUMPER__, ctxadh2_.NUMLMD as NUMLMD__, ctxadh2_.NUMPER as NUMPER1_, ctxadh2_.NUMLMD as NUMLMD1_, ctxadh2_.EFFADE as EFFADE1_, ctxadh2_.LIDCRE as LIDCRE1_, ctxadh2_.DEVISE as DEVISE1_, ctxadh2_.DATCRE as DATCRE1_ from ccd_contrat contrat0_ left outer join ccd_etat etat1_ on contrat0_.NUMLMD=etat1_.NUMLMD left outer join ccd_adherente ctxadh2_ on contrat0_.NUMLMD=ctxadh2_.NUMLMD where contrat0_.NUMLMD=?
15:20:41,321?DEBUG BatcherImpl:241 - preparing statement
15:20:41,321?DEBUG StringType:46 - binding '358 ' to parameter: 1
15:20:41,321?DEBUG Loader:197 - processing result set
15:20:41,337?DEBUG StringType:68 - returning '358 ' as column: NUMLMD0_
15:20:41,337?DEBUG StringType:68 - returning 'nico1111' as column: NUMPER1_
15:20:41,337?DEBUG StringType:68 - returning '358 ' as column: NUMLMD1_
15:20:41,337?DEBUG SessionImpl:1982 - loading [lm.met.vo.Contrat#358 ]
15:20:41,337?DEBUG SessionImpl:2079 - attempting to resolve [lm.met.vo.Contrat#358 ]
15:20:41,337?DEBUG SessionImpl:2112 - object not resolved in any cache [lm.met.vo.Contrat#358 ]
15:20:41,337?DEBUG EntityPersister:416 - Materializing entity: [lm.met.vo.Contrat#358 ]