Home » Support » Forum » Problem with 'where' and date()

Problem with 'where' and date()

#1

Hi,

Today I was playing with some date-range queries in explorer and found a small problem. When you try to use queries like this:

SELECT o from TestObject o where o.date > :someDate

where o.date is java.util.Date, 'where' doesn't work as it should. Results are not filtered by date. There is no such problem in code because we can set Date() object as parameter. However this is hard in explorer.

You can find UTC attached to this post.

 

#2

You can run queries with dates in the Explorer by using date literals. For example:

SELECT o FROM TestObject o WHERE o.date > {d '2011-07-01'}

Date parameters should also be supported by the Explorer, but the question is how exactly to do that. In the application you can define a date format (as demonstrated in your test). In the Explorer the format is unknown so parsing a date from a string may be problematic. Is there a generic method in Java that can handle different formats of date and time?

Maybe the Explorer should identify the parameter as a date parameter and replace the text field in that case automatically with a date editor.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login