Hi Guys,
I am trying to write a simple query where I am just subtracting two timestamps from DB.
Code:
select ticket_status, count(ticket_status), trunc (to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM')-to_date('2004/12/12 4:29 PM', 'YYYY/MM/DD HH:MI PM')) as days
from ITS_TICKET_MASTER group by ticket_status, trunc (to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM')-to_date('2004/12/12 4:29 PM', 'YYYY/MM/DD HH:MI PM'))
This Query is giving me the result i wanted..
But............
When I am trying the same query in HQL then it is giving me error.
Code:
QueryImpl(select ticketStatus, count(ticketStatus), trunc (to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM')-to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM')) as days from WebTicket group by ticketStatus, trunc (to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM')-to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM')))
Hibernate: select webticket0_.TICKET_STATUS as col_0_0_, count(webticket0_.TICKET_STATUS) as col_1_0_, trunc(to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM')-to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM')) as col_2_0_ from ITS_TICKET_MASTER webticket0_ group by webticket0_.TICKET_STATUS , trunc(to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM')-to_date('2004/12/14 4:29 PM', 'YYYY/MM/DD HH:MI PM'))
org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1565)
at org.hibernate.loader.Loader.list(Loader.java:1545)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:840)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.service.FetchFormService.fetchFormDetailsforAgeingReportDayWise(FetchFormService.java:170)
at com.functionalService.FetchFormFunctionalService.fetchFormDetailsforAgeingReportDayWise(FetchFormFunctionalService.java:275)
at com.actionClass.AgeingReportAction.fetchAgeingReport(AgeingReportAction.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:276)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:196)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.jsp.LMS_jsp._jspService(LMS_jsp.java:54)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: Invalid column type: getTimestamp not implemented for class oracle.jdbc.driver.T4CNumberAccessor
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271)
at oracle.jdbc.driver.Accessor.unimpl(Accessor.java:375)
at oracle.jdbc.driver.Accessor.getTimestamp(Accessor.java:808)
at oracle.jdbc.driver.OracleResultSetImpl.getTimestamp(OracleResultSetImpl.java:1060)
at oracle.jdbc.driver.OracleResultSet.getTimestamp(OracleResultSet.java:512)
at org.hibernate.type.TimestampType.get(TimestampType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.loader.hql.QueryLoader.getResultColumnOrRow(QueryLoader.java:337)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:321)
at org.hibernate.loader.Loader.doQuery(Loader.java:395)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:210)
at org.hibernate.loader.Loader.doList(Loader.java:1562)
... 45 more
I dont have any answer to this.. Please suggest where am i doing wroing.