0 Replies Latest reply on Sep 4, 2007 6:12 PM by Steven Gollery

    update to hibernate 3.2.5 causes query exception

    Steven Gollery Newbie

      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">
       <id name="id" column="patient_key" type="long">
       <generator class="native" />
       <set name="studiesSubmittedTo" table="Patient_Studies"
       <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>

      This query is supposed to return only those patients that have at least one element in their studiesSubmittedTo collection whose date is at or after some other date. The element also has to not have a certain list of values for the status, but I think that's not part of the problem.

      So: why did this query work in 3.2.1 but not in 3.2.5, and is there some other query that would accomplish the same thing and be acceptable to 3.2.5?

      Thanks in advance.

      Steven Gollery