| 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 |
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
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
Mar 10, 2013
use date literal like this....
where date={d ?1};
query.setParameter(1,"2011-09-04");
|
a workaround is using param("myDate",Date.class) ... query.setParameter("myDate",dateObj);