Hi Marc,

I think you have to decide if you need the time stored in the database, or if that's just an artifact of the implementation.

If you need the time, then you might have to do a range comparison by calculating the date with time and adding a day, then comparing x.created > some_date and x.created < some_date_plus_one_day.

If you don't need the time, then you need to strip off the time part of the date before you store it. Then an equality comparison with a date will work. Calendar functions can do this for you. Simply doing created = new Date() won't do it.

Craig

On Sep 3, 2008, at 4:05 PM, Marc Logemann wrote:

Hi,

suppose i have a datetime field "created" in the DB which is mapped by JPA to a java.util.Date attribute in my domain class.

Now i want to create a query which is something like:

"select x from Order x where x.created = current_date"

The problem is. This never matches because current_date represents only the current date and in my Date attribute we have a complete Date with time. My intention is to compare just the date, but i have a java.util.Date attribute. It seems thats not possible at all.

Anyone with ideas? Thanks.

--
Marc Logemann
blog http://logemannreloaded.blogspot.com
privat http://www.logemann.org




Craig L Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:[EMAIL PROTECTED]
P.S. A good JDO? O, Gasp!

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to