I'm trying to move from hibernate 3.2.1 to 3.2.5, but I've run into a query that used to work and now throws this exception:
Illegal attempt to dereference collection [patient0_.patient_key.studiesSubmittedTo] with element property reference [submittedDate]...
The query code looks like this:
Date cutoffDate = new Date((new Date()).getTime() - weeksToMillis(pendingPatientCutoff));
String qStr = "select distinct p from Patient p where p.studiesSubmittedTo.submittedDate >= :date and p.studiesSubmittedTo.status != 'Randomized' and p.studiesSubmittedTo.status != 'NotRandomized' and p.studiesSubmittedTo.status != 'Billed' order by p.lastName";
Query q = session.createQuery(qStr);
q.setParameter("date", cutoffDate);
List patients = (List)q.list();
The mapping for studiesSubmittedTo defines a composite-element in the Patient mapping. The relevant part of the mapping file is this:
<hibernate-mapping package="model"> <class name="Patient" table="Patient"> <id name="id" column="patient_key" type="long"> <generator class="native" /> </id> <set name="studiesSubmittedTo" table="Patient_Studies" cascade="all"> <key column="patient_key"/> <composite-element class="StudyPatientAssociation"> <parent name="patient"/> <property name="submittedDate" type="date"/> <property name="status"> <type name="userTypes.GenericEnumUserType"> <param name="enumClass">model.StudyPatientAssociation$Status</param> </type> </property> </composite-element> </set> </hibernate-mapping>