-->
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.  [ 3 posts ] 
Author Message
 Post subject: Oracle and lazy collections
PostPosted: Sat May 21, 2005 8:15 am 
Newbie

Joined: Sat May 21, 2005 8:02 am
Posts: 6
Hi. I'm quiet new to Hibernate, so this may be some misunderstanding.
I'm using version 3.0.3. All associations are lazy. In spite of that
Hibernate loads not only the object I want to retrieve from Oracle, but
recursively all objects associated with it.

I've investigated the code. The constructor of org.hibernate.type.EntityType
has a parameter "eager", which is in my case "true". So it is clear why
Hibernate loads all these objects.
Looking at the constructor of EntityType's subclass ManyToOneType I see
a parameter "lazy" which is "true", and is inverted before being passed
to the superclass.

In my understanding Hibernate supports three types of Laziness, "true",
"false" and "proxy". How is it there is a boolean parameter, and why is
this parameter inverted?

For the time being I will have to fake the constructor of EntityType, but
comments on this are appreciated.

Thanks,
Erik


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2005 11:09 am 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
Hibernate supports 2 modes EAGER or LAZY: If you set LAZY=TRUE, hibernate will create a proxy and load the association when you will try to access it the first time. If you set it to false, the association will be eagerly loaded.

You do not need to overwrite any constructor for that :)

Please post your mapping documents etc. if you can not make it work.

Regards,
Vincent

_________________
Vincent Giguère
J2EE Developer


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2005 7:43 pm 
Newbie

Joined: Sat May 21, 2005 8:02 am
Posts: 6
This is an example of a mapping file:

<?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 auto-import="false" default-lazy="true">

<class name="Dispo.Hibernate.Dispo.Disposition"
table="Disposition">

<id name="Oid" type="long"/>

<property name="Schreibzaehler" type="long"/>
<property name="IstGeloescht" type="boolean"/>
<property name="Valutatag" type="long">
<column name="Valutatag" index="Disposition_Valutatag"/>
</property>
<property name="Handelstag" type="long">
<column name="Handelstag" index="Disposition_Handelstag"/>
</property>
<property name="Waehrungskurs" type="string"/>
<property name="Bemerkung" type="string"/>
<property name="UmrechnungIstBetragNachGegenbetrag" type="boolean">
<column name="Umrechnung"/>
</property>
<property name="BetragIstHaben" type="boolean"/>
<property name="GegenbetragIstHaben" type="boolean"/>
<property name="EingangBetrag" type="integer"/>
<property name="EingangGegenbetrag" type="integer"/>
<property name="Referenz" type="string">
<column name="Referenz" index="Disposition_Referenz"/>
</property>
<property name="Referenz2" type="string">
<column name="Referenz2" index="Disposition_Referenz2"/>
</property>
<property name="ZurZahlungVorgemerkt" type="boolean"/>
<property name="CLSStatus" type="integer"/>

<property name="DerBetrag" type="string"/>
<many-to-one name="dieWaehrung" column="DispositionWaehrung" lazy="true" index="IndexDispositionWaehrung"
class="Dispo.Hibernate.Stamm.Waehrung"/>

<property name="DerGegenbetrag" type="string"/>
<many-to-one name="dieGegenwaehrung" column="DispositionGegenwaehrung" lazy="true" outer-join="false" index="IndexDispoGegenwaehrung"
class="Dispo.Hibernate.Stamm.Waehrung"/>

<!-- many-to-one-Assoziation Disposition.dasBuchungskontoWaehrung <-> Buchungskonto.dieDispositionenWaehrung -->
<many-to-one name="dasBuchungskontoWaehrung" column="BuchkontoDispoWaehrung"
lazy="true" outer-join="false" index="IndexBuchkontoDispoWaehrung"
class="Dispo.Hibernate.Stamm.Buchungskonto"/>

<!-- many-to-one-Assoziation Disposition.dasBuchungskontoGegenwaehrung <-> Buchungskonto.dieDispositionenGegenwaehrung -->
<many-to-one name="dasBuchungskontoGegenwaehrung" column="BuchkontoDispGegenwaehrung"
lazy="true" outer-join="false" index="IndBuchkontoDispoGegenwaehrung"
class="Dispo.Hibernate.Stamm.Buchungskonto"/>

<!-- many-to-one-Assoziation Disposition.dieDispoart <-> Dispoart.dispositionen -->
<many-to-one name="dieDispoart" column="DispositionDispoart" lazy="true" outer-join="false" index="IndexDispoDispoart"
class="Dispo.Hibernate.Dispo.Dispoart"/>

<!-- many-to-one-Assoziation Disposition.dasHandelsportfolio <-> Handelsportfolio.dispositionen -->
<many-to-one name="dasHandelsportfolio" column="DispositionHandelsportfolio" lazy="true" outer-join="false" index="IndexDispoHandelsportf"
class="Dispo.Hibernate.Stamm.Handelsportfolio"/>

</class>

</hibernate-mapping>



Is there something that is obviously wrong?

Whatsoever, I do not understand why this "lazy" flag is inverted in the
code.

There is another post which seems to deal with a similar problem:
http://forum.hibernate.org/viewtopic.ph ... racle+lazy

Thanks in advance,
Erik Heckert


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

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.