My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 29: Fix the Date literals, JPA don't support it!
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Dec 2008


 
Reported by java.ma...@gmail.com, Dec 11, 2008
We cant use Dates directly in the query, because produce a default 
Date.toString(). 

For example:

where(between(p.getSomeDate(),new Date(), anotherDate))

throws parser error from JPA provider (hibernate in my case)


Dec 11, 2008
#1 java.ma...@gmail.com
a workaround is using param("myDate",Date.class)
...
query.setParameter("myDate",dateObj);
Dec 11, 2008
Project Member #2 eric.bot...@gmail.com
Indeed JPA doesn't support date literals.

What you describe is not really a _workaround_ but the way to use parameters (when
literals are supported, eg. with numbers, one can use literals _or_ parameters).

The framework will be updated to fail early (throwing an exception when it encounters
a date "literal" and driving the developer towards the param() construct in case this
is what she intended)
Labels: -Type-Defect Type-Enhancement Milestone-Release1.0
Dec 12, 2008
Project Member #3 eric.bot...@gmail.com
Fixed in r102
Status: Fixed
Mar 10, 2013
#4 anshul.k...@gmail.com
use date literal like this....

where date={d ?1};

query.setParameter(1,"2011-09-04");

Powered by Google Project Hosting