A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
Object Relational Mapping
invoke functions in a jpl query
Joined: Apr 08, 2011
Apr 02, 2012 01:49:33
SQL_QUERY ="select a from Appointment a where a.appointmentDate.getDate()" +" =:date" + "and a.appointmentDate.getMonth()=:month and a.appointmentDate.getYear()=:year" ;
Query query = session.createQuery(SQL_QUERY);
Can i invoke functions like a.appointmentDate.getMonth() in a jpl query ?
Thnks in advance
Joined: Oct 01, 2007
Apr 02, 2012 08:13:29
No, unfortunately JPQL does not have any date functions.
Since you are querying each part though, you could just use = :date and use a Date parameter.
Otherwise, you will need you use something provider specific, or a native SQL query.
If you are using EclipseLink, you could use the FUNC JPQL operator to call a database specific date function.
Blog:Java Persistence Performance
I agree. Here's the link:
subject: invoke functions in a jpl query
Using date part of a datetime in group by clause
Hibernate Date mapping
Passing Date from HTML Form to JSP/Action Handler
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013