Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

invoke functions in a jpl query

 
yogessh chavaan
Greenhorn
Posts: 13
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic