jpa - How to call a SQL function like "HOUR()" in a @NamedQuery in Java Persistence -


I should know how the SQL function such as HOUR () a @NamedQuery
To make it simple, in one row in the initial time ( TIMESTAMP ) column, I need to get the rows that are CURRENT_TIMESTAMP and Starting between HOOR (CURRENT_TIMESTAMP) +1 I have spent a day on Google and have not yet managed to find the answer The following query works when we try with JAVADB , but the same failed in @NamedQuery lives.

Java DB Example :

  select e.EMPLOYEEID, e.FIRSTNAME, r.STARTTIME, r.ENDTIME reservationR, employee E Where e.EMPLOYEEID = r.EMPLOYEEID and hours (from .STARTTIME) = this hour (CURRENT_TIMESTAMP)   

@NamedQuery :

  @NamedQuery (name = "reservation.getcurrent", query =)  reservation R, employee E where e.EMPLOYEEID = r.EMPLOYEEID and hours (r.STARTTIME) = this hour (CURRENT_TIMESTAMP) e. EMPLOYEEID, e.FIRSTNAME, r.STARTTIME, r.ENDTIME Choose ">  

Error:

  [2014-04-22T17: 03: 00.946 + 0530] [Glassfish 4.0] [Saver] [] [javax.enterprise.system.core] [tid: _ThreadID = 38 _ThreadName = admin- (5) [timeMillis: 1398166380946] [levelValue: 1000] [[Deployment Execution of Application [LyndaPortalReservation]: Exceptions [EclipseLink-28019] (Eclipse Stagnant Services - 2.5. 0.v201 30507-3faac2b): org.eclipse. Persistence.exceptions.EntityManagerSetupException exception description: Continuity deployment unit [Landa Portal Reservation PU] failed. Close all the factories for this firmness unit Internal Exception: Exception [EclipseLink-0] (Eclipse Attachment Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.JPQLException Exception Description: Syntax Error Pars [ Selection e.EMPLOYEEID, e.FIRSTNAME, R. RTRTEM, RRRDRRR, in employee E where E. EmoIIDID = REMPiloidID and HOOR (RTTPETE) = HOOR (CRERITMTMAM)]. [126, 16 9] The correct expression is not a valid expression.]]    

For clarity, I've added the exact syntax to declare a function in JPQL. @Niile was right but the use of double quotation did not work for the name of the function. The syntax for the function name was FUNC ('funcName', args) We need to use single quotation marks. So other users are looking for the same answer. Here's the exact syntax.

@NamedQuery (name = "reservation.getall", query = "SELECT e.employeeid, e.firstname, r.starttime, r.endtime RRR, employee E where e. Employeeid = r.employeeid and function ('this hour', r.starttime) = function ('this hour', CURRENT_TIMESTAMP) ")

Help to solve its basic problem of Using the Function in HQL

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -