Hi everyone. I cannot execute a "simple" query. What am I wrong?
Utenza mapping:
Code:
<hibernate-mapping package="domain">
<class name="Utenza">
<id name="id">
<generator class="native" />
</id>
<property name="nome" />
<set name="tabulati" lazy="true" inverse="true" cascade="all" >
<key column="utenza" />
<one-to-many class="Tabulato" />
</set>
</class>
</hibernate-mapping>
Tabulato mapping:
Code:
<hibernate-mapping package="domain" >
<class name="Tabulato">
<id name="id">
<generator class="native" />
</id>
<property name="archiviazione" />
<many-to-one name="utenza" column="utenza" class="Utenza" not-null="true"/>
<set name="chiamate" lazy="true" inverse="true" cascade="all">
<key column="tabulato" />
<one-to-many class="Chiamata" />
</set>
</class>
</hibernate-mapping>
The following query:
Code:
List<Utenza> utenze = s.createQuery("from Utenza U, Tabulato T where U.tabulati.invio is null").list();
gives the following error:
Code:
illegal attempt to dereference collection [utenza0_.id.tabulati] with element property reference [invio] [from domain.Utenza U, domain.Tabulato T where U.tabulati.invio is null]
...
and the following query:
Code:
List<Utenza> utenze = s.createQuery("from Utenza U, Tabulato T where T.utenza = U.id and T.invio is null").list();
gives the following error:
Code:
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to domain.Utenza
What's wrong?
I'd to retrieve all "Tabulato" which have invio = null joined with their Utenza.
Thx for any help