persistence@glassfish.java.net

Re: Mapping of CURRENT_DATE, CURRENT_TIMESTAMP, CURRENT_TIME functions of JPA

From: Tom Ware <tom.ware_at_oracle.com>
Date: Thu, 04 Jan 2007 08:51:36 -0500

Hi Mitesh,

  You are correct. To get the current timestamp, currentDate() should
be used.

-Tom

Mitesh Meswani wrote:

>Hi Michael,
>The current code for query compiler maps all of these functions to
>Expression#currentDateDate(). Some databases(for example derby)
>distinguish between a TIMESTAMP type and DATE type.
>For example the attached program which tries to update a TIMESTAMP field
>on derby using "Update Employee e set e.testTimeStamp =
>CURRENT_TIMESTAMP" generates sql "UPDATE EMPLOYEE_TBL SET TESTTIMESTAMP
>= CURRENT DATE" which is not accepted by Derby. It is obvious that we
>will need to map this functions to different expressions
>
>Tom,
> From javadocs in Expression.java, it seems that CURRENT_DATE should be
>mapped to Expression#currentDateDate() (ExpressionOperator.currentDate)
>and CURRENT_TIMESTAMP should be mapped to Expression#currentDate()
>(ExpressionOperator.Today) . Is that correct?
>
>Thanks,
>Mitesh
>
>
>