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>
  | 
  | 

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

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081114#4081114

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081114
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to