Craig,
thanks for your answer. I got the message but somehow it feels that
this is a JPA shortcoming.
I definitely want to store a complete DATETIME field in my DB because
i most likely need the complete time for some things within my app.
But for this one query, the only interessting thing is the date
without time.
Of course the range thingy would somehow work but its ugly. What i am
missing is something like this:
select x from Order x where date(x.created) = current_date
so a date() function on JPA level or something. Or how about general
date related functions at all.
Similary there could be time() or timestamp() functions that modify
the value of x.created before sending it to the DB.
Is this a weird idea? Can one do this with custom functions in OpenJPA ?
--
Marc Logemann
blog http://logemannreloaded.blogspot.com
privat http://www.logemann.org
Am 04.09.2008 um 01:32 schrieb Craig L Russell:
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!