Hibernate version: 1.2.1 GA
Name and version of the database you are using: SQL Server 2005
Hi,
I have a problem fetching a collection inside a subclass.
This is the mapping:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Simplico.Business.Anagrafica.Entities" assembly="SimplicoRealEntities">
<class name="EntitaLegale" table="EntitaLegale" lazy="false">
<id name="Id" column="Id" type="Int64">
<generator class="identity"/>
</id>
<property name="PartitaIVA" type="String"/>
<property name="CodiceFiscale" type="String"/>
<many-to-one name="Sede" class="Indirizzo,Anagrafica" column="Indirizzo_Id" foreign-key="fk_EntLeg_sede"/>
<bag name="RelazioniEntita1">
<key column="Entita1_Id"/>
<one-to-many class="Relazione"/>
</bag>
<bag name="RelazioniEntita2">
<key column="Entita2_Id"/>
<one-to-many class="Relazione"/>
</bag>
<joined-subclass name="Persona" table="Persona" lazy="false">
<key column="EntitaLegale_Id"/>
<property name="Nome" column="Nome" type="String" length="20"/>
<property name="Cognome" type="String" length="20"/>
<many-to-one name="Residenza" class="Indirizzo, Anagrafica" column="Residenza_Id" foreign-key="fk_Pers_residenza"/>
<many-to-one name="Domicilio" class="Indirizzo, Anagrafica" column="Domicilio_Id" foreign-key="fk_Pers_domicilio"/>
</joined-subclass>
<joined-subclass name="Societa" table="Societa" lazy="true">
<key column="EntitaLegale_Id"/>
<property name="Nome" column="Nome" type="String" length="20"/>
<property name="Ragione" type="String"/>
</joined-subclass>
</class>
<class name="Relazione" table="Relazione">
<id name="Id" column="Id" type="Int64">
<generator class="identity"/>
</id>
<property name="TipoRelazione" type="Simplico.Business.Anagrafica.Entities.EnumTipoRelazione, SimplicoRealEntities"/>
<many-to-one name="Entita1" class="EntitaLegale" column="Entita1_Id" foreign-key="fk_Rel_entita1" />
<many-to-one name="Entita2" class="EntitaLegale" column="Entita2_Id" foreign-key="fk_Rel_entita2"/>
<many-to-one name="Contratto" class="Simplico.Business.Contabilita.Entities.Contratto" column="Contratto_Id" foreign-key="fk_Rel_contratto"/>
</class>
EntitaLegale is a C# abstract class.
When I fetch an element of type Persona (a subclass), then try to access the collection RelazioniEntita1 (a superclass property), I always get a collection of 0 elements.
I tryed with set or bag, with or without proxy, lazy or eager... always the same result.
I'm sure I made some mistake, but I don't know where.
Can you please tell me where am I wrong ?
Thanks.
Best Regards,
Edoardo