aspose file tools
The moose likes Object Relational Mapping and the fly likes invoke functions in a jpl  query Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "invoke functions in a jpl  query " Watch "invoke functions in a jpl  query " New topic
Author

invoke functions in a jpl query

yogessh chavaan
Greenhorn

Joined: Apr 08, 2011
Posts: 13

String 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);
query.setParameter("date", date);
query.setParameter("month", month);
query.setParameter("year", year);

Can i invoke functions like a.appointmentDate.getMonth() in a jpl query ?

Thnks in advance
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 550
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.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: invoke functions in a jpl query
 
Similar Threads
Using date part of a datetime in group by clause
Date object
Hibernate Date mapping
Passing Date from HTML Form to JSP/Action Handler
scalar functions