-->
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: joined-subclass: superclass one-to-many property not loading
PostPosted: Fri Dec 21, 2007 1:31 pm 
Newbie

Joined: Fri Dec 21, 2007 1:17 pm
Posts: 11
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


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 22, 2007 10:14 am 
Newbie

Joined: Fri Dec 21, 2007 1:17 pm
Posts: 11
After I tried every possible case I identified the problem, but I don't have a solution. It could be a bug or, with higher probability, a thing I don't know about.
The problem is with the two relations from EntitaLegale to Relazione. If I insert only one relation things go well, but inserting the second association the collections are always empty and fetching doesn't happen.

I really don't know how can I solve this problem...

I will appreciate any suggestion.

Thanks for your patience.

Best regards,
Edoardo


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 24, 2007 11:28 am 
Newbie

Joined: Fri Dec 21, 2007 1:17 pm
Posts: 11
I apologize for having wasted your time... the problem was a cut&paste error...

Sorry.


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.