Goal: Retrieve a collection of objects with dates between X and Y

Current Implementation:

Event.java (Business Object) contains:
java.util.Date startDate

repository.xml maps:
<field-descriptor name="startDate" column="StartDate" jdbc-type="TIMESTAMP"/>


PB Query:
Criteria criteria = new Criteria();
criteria.addBetween("StartDate", startDate, endDate);
Query query = QueryFactory.newQuery(Event.class, criteria);

where startDate and endDate are java.util.Dates.

When this query executes, I receive no errors about converting from TIMESTAMP to java.util.Date... and I DO receive results..... I receive ONLY records where the StartDate column is 0000-00-00 00:00:00... or blank in other words. Why is it matching blank records when I am attempting to find records between date X and date Y?

I get similar results when using the addGreaterOrEqualThan submitting startDate. In this case I receive ALL records (including those with 0000-00-00 00:00:00).

If you'd rather ignore all the above... I'd like to see best practices for using java.util.Dates with OJB (I'm using mySQL DateTime columns).

Thanks,
Aaron Longwell


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to