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: Lazy Loading
PostPosted: Wed May 31, 2006 1:53 pm 
Beginner
Beginner

Joined: Fri May 12, 2006 10:48 am
Posts: 33
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: Wed May 31, 2006 8:52 pm 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
I don't think this is an nhibernate problem, you probably just need to override the ToString() method on your Sector class and have it return the description.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 01, 2006 8:53 am 
Beginner
Beginner

Joined: Fri May 12, 2006 10:48 am
Posts: 33
Hi grennis, thanks for your reply.
When I listed the Sector objects and watched the list, I noticed that the Sector objects (that were loaded at the first time when I loaded the Empresa objects) are CProxyTypeSectorCommon_INHibernateProxy_ISerializable2 and the new Sector objects that were just loaded to fill the ComboBox are Common.Sector, both are in the same list and the latest objects are the ones that don’t show their Description in the ComboBox.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.