I've problems mapping a join with Hibernate 3.2
here is the mapping:
<hibernate-mapping>
<class name="it.studio.models.ProgettoCapoModel" table="Progetto">
<id name="capo"/>
<property name="id"/>
<property name="nome"/>
<property name="descrizione"/>
<join table="Impiegato">
<key column="cf"/>
<property name="nomeCapo" column="nome"/>
<property name="cognomeCapo" column="cognome"/>
</join>
</class>
</hibernate-mapping>
But it doesn't work well.
If there are two "progetto" with the same "capo", in the result I'll get two times the first one.
Eg.
I got:
Id Nome nomeCapo
1 P1 Pippo
2 P2 Pluto
2 P2 Pluto
3 P3 Mikey
3 P3 Mikey
but should be:
Id Nome nomeCapo
1 Proj1 Pippo
2 Proj2 Pluto
4 Proj4 Pluto
3 Proj3 Mikey
5 Proj5 Mikey
I've tried to invert "Progetto" with "Impiegato", but the result is the same.
I've checked the query made by Hibernate, but it looks correct.
|