I have this code which was working with hibernate 3.1.3 but for other reasons i had to install 3.2.3 this morning and now i get a
Code:
org.hibernate.QueryException: illegal attempt to dereference collection
when i try to execute de code
Code:
int count = ((Integer) session.createQuery("select count(*) from Appellant ap where (ap.sectors in (:sectorsIds))").setParameterList("sectorsIds", sectorsIdArray).iterate().next()).intValue();
where sectorsIdArray is an array that contains indexes of sectors in which i am interested.
The mapping files are:
Appellant.hbm.xml
Code:
<hibernate-mapping>
<class name="org.ai.kandelo.beans.Appellant" table="APPELLANTS" lazy="false">
<id name="id" column="APPELLANT_ID" unsaved-value="0">
<generator class="native"/>
</id>
<property name="name" not-null="true"/>
<property name="surname"/>
<property name="address"/>
[...]
<set name="sectors" table="APPELLANTS_TO_SECTORS" lazy="false">
<key column="APPELLANT_ID"/>
<many-to-many column="SECTOR_ID"
class="org.ai.kandelo.beans.Sector"/>
</set>
</class>
</hibernate-mapping>
and
Sector.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.ai.kandelo.beans.Sector" table="SECTORS" lazy="false">
<id name="id" column="SECTOR_ID">
<generator class="native"/>
</id>
<property name="nameKey" not-null="true"/>
<property name="visible"/>
</class>
</hibernate-mapping>
The query i wanted to do is "give me all the appellants that have any on the indexes passed by me within it set sectors"
The strange thing is that it was working until i changed to version 3.2.3.
Thanks in advance and excuse me for my poor english. I promise to rank you if you give me any idea.