-->
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: Problem with lazy load
PostPosted: Thu Jun 15, 2006 10:34 am 
Beginner
Beginner

Joined: Fri May 12, 2006 10:48 am
Posts: 33
Posted: Wed May 31, 2006 5:53 pm Post subject: Lazy Loading

I asked before about loading many-to-one relation in a lazy way. I should add to my mapping files “Lazy=true” in the class definition and then declare the class properties as Overridable.
Now I’m having the following problem. I have these classes.

<class name=" Empresa " table="Empresas" lazy="true">
<id name="Id" type="Int32" unsaved-value="0">
<column name="idEmpresa" sql-type="int" not-null="true" unique="true" />
<generator class="native" />
</id>
<property name="Codigo" type="String">
<column name="codEmpresa" length="4" sql-type="char" not-null="true" unique="true" />
</property>
<property name="Descripcion" type="String">
<column name="Descripcion" length="60" sql-type="char" not-null="true"/>
</property>
<many-to-one name="Sector" class="Sector">
<column name="IdSector" sql-type="int" not-null="false"/>
</many-to-one>
</class>

And

<class name="Sector " table="Sectores" lazy="true">
<id name="Id" type="Int32" unsaved-value="0">
<column name="IdSector" sql-type="int" not-null="true" unique="true" />
<generator class="native" />
</id>
<property name="CodSector" type="String">
<column name="codSector" length="3" sql-type="char" not-null="true"/>
</property>
<property name="Descripcion" type="String">
<column name="Descripcion" length="60" sql-type="varchar" not-null="true"/>
</property>
</class>

When I load first a list with Empresas, first a “Select” on Empresas table is done and then, several selects on Sector table are done (one for each Object Empresa that I show in the list), all this works fine but when I load a ComboBox with Sectores and a new Select on Sectores table is done, the new Sector objects (that weren’t loaded in the Empresas List) don’t show their Description in the ComboBox, they show “Sector” (their namespace) instead.
Could anybody help me?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 12:01 pm 
Regular
Regular

Joined: Sun Feb 12, 2006 10:18 pm
Posts: 60
Location: Rosario, Argentina
I think it's because the ComboBox shows the object.ToString(). Try overriding ToString() in each class to write the text tou need.

Que feo tener que responder en inglés... ché, te funcionó a vos lo del lazy load? a mi parece no funcionarme...

Alejandro.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 15, 2006 1:17 pm 
Beginner
Beginner

Joined: Fri May 12, 2006 10:48 am
Posts: 33
Thanks for your reply.
The Sectores ComboBox shows Descripcion Property, the problem is that the list with objects Sector has two object types, one of them is CProxyTypeSectorCommon_INHibernateProxy_ISerializable2
and the other, Common.Sector.
The CProxyTypeSectorCommon_INHibernateProxy_ISerializable2 object has a lot of aditional properties.
If the quantity of CProxyTypeSectorCommon_INHibernateProxy_ISerializable2 is greater than the quantity of Common.Sector objects, then the comboBox just shows the CProxyTypeSectorCommon_INHibernateProxy_ISerializable2.


A mi si me funciona el lazy load, lo que tenes que hacer es agregar lazy=true en la definicion de cada mapping y declarar overridable todas las propiedades the los objetos.


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.