hi all,
I'm trying to create a Criteria query that filters on an association with the criteria class. I'm able to run the query with no problems using simple properties. it's the associations that I'm having troubles with. I'm using Hibernate 2.1.7.
I have a Patient class and a set of patient status' for a given patient. I keep a record of status changes, so there's a collection of them.
Patient class
<hibernate-mapping default-cascade="none">
<class name="edu.test.persistence.PatientImpl" table="PATIENT">
<set name="patientstatusevents" order-by="PATIENT_ID" lazy="true" inverse="true">
<key>
<column name="PATIENT_ID"/>
</key>
<one-to-many class="edu.test.persistence.PatientstatuseventImpl"/>
</set>
</class>
</hibernate-mapping>
I'm able to create a criteria/query on the simple attrs, like lastName. Here's how I construct the Criteria
// Works fine
Criteria criteria = session.createCriteria(edu.test.persistence.Patient.class);
criteria.add( Expression.like("lastName", "Smith");
My problem comes trying to get a reference to the set of statusEvents. I've tried...
// stackTrace
Criteria statusEventsCriteria = criteria.createAlias("patientstatusevents", "statusEvents");
this should get me an alias to the set, but this gives me a stackTrace.
springframework.orm.hibernate.HibernateSystemException: Unknown entity class: edu.test.persistence.Patient; nested exception is net.sf.hibernate.MappingException: Unknown entity class: edu.test.persistence.Patient
this seems fairly simple and straightforward, yet I don't understand why I can't create the alias...ideas/help??
thanks jim
|