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?
|