Sure!
I cut off many things to make the example as simple as possible.
This is the mapping:
Code:
<class name="Task" table="Task">
<id name="Id" column="Id" type="Int64">
<generator class="identity"/>
</id>
<set name="Risorse" inverse="true" cascade="save-update">
<key column="Task_Id"/>
<one-to-many class="Risorsa"/>
</set>
<property name="StatoTask"/>
<property name="TipoTask" type="Simplico.Business.Seteco.Entities.EnumTipoTask, SetecoEntities"/>
<property name="DataInizio" type="Date"/>
<property name="DataFine" type="Date"/>
<property name="PercentualeCompletamento" type="Single"/>
</class>
<class name="Risorsa" table="Risorsa">
<id name="Id" column="Id" type="Int64">
<generator class="identity"/>
</id>
<many-to-one name="TaskGS" class="Task" column="Task_Id" foreign-key="fk_Risorsa_Task"/>
<property name="DataInizio" type="Date"/>
<property name="DataFine" type="Date"/>
<property name="DataInserimento" type="Date"/>
<joined-subclass name="RisorsaEconomica" table="RisorsaEconomica">
<key column="Risorsa_Id"/>
<property name="Valore" type="Decimal"/>
</joined-subclass>
<joined-subclass name="RisorsaUomo" table="RisorsaUomo">
<key column="Risorsa_Id"/>
<property name="Ore" type="Single"/>
<many-to-one name="RelazioneGS" class="Simplico.Business.Anagrafica.Entities.Relazione" column="Relazione_Id" foreign-key="fk_Risorsa_Relazione"/>
</joined-subclass>
</class>
And this is a sample query:
Code:
string qry = "SELECT sum(ris.Ore) FROM Task t INNER JOIN t.Risorse ris GROUP BY ris.DataInizio";
The resulting query is:
Code:
select sum(risorse1_2_.Ore) as x0_0_ from Task task0_ inner join Risorsa risorse1_ on task0_.Id=risorse1_.Task_Id group by risorse1_.DataInizio
The resulting error is quite obvious, risorse1_2_ doesn't exist.
Changing the mapping file having only one table for the hierarchy, with discriminators, everything goes fine.