I am unable to compare dates in MySQL queries. I'm trying to get all rows newer than a certain date by comparing the theDate column to a passed in parameter. I've tried explicitly stating the type in the mapping file with no luck. I was able to similarly compare integer fields, so I can't be too far off.
I keep getting the following error:
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: 9, of class: com.mypackage.OtherClass
Perhaps there's a mapping error, but why would it give me an object not found error on a completely different class than the one I'm querying?
Here's more info:
from persisted bean class (called Bean)
private Date theDate;
from mapping file:
<property name="theDate"/>
GregorianCalendar cal = new GregorianCalendar();
cal.set(2003,1,1);
StringBuffer buffer = new StringBuffer("select bean from Bean bean where (bean.theDate) > :aDate");
... later ...
Query q = session.createQuery(buffer.toString());
q.setDate("aDate",cal.getTime());
results = q.list();
Any help appreciated!
|