tags:

views:

370

answers:

0

I have a query looks like this

@NamedQuery(name="WorkingDayLog.getExpectedWorkingHours",query="select ((count(o.id)-:approvedVacs)*(:shiftDuration/60.0)*:factor) from WorkingDayLog o where o.workingDayDate between :appraisalStart and :appraisalEnd")`

it compiles fine but when executed it throws the following exception

ClassCastException: java.lang.Double cannot be cast to java.lang.Long

and this is the full stack trace

`java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Long
 at org.hibernate.type.LongType.set(LongType.java:65)
 at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:154)
 at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
 at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:61)
 at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:514)
 at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1589)
 at org.hibernate.loader.Loader.doQuery(Loader.java:696)
 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
 at org.hibernate.loader.Loader.doList(Loader.java:2228)
 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
 at org.hibernate.loader.Loader.list(Loader.java:2120)
 at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
 at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
 at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
 at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
 at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)
 at com.edc.hrms.dao.impl.BaseDAOImpl.executeQuery(BaseDAOImpl.java:213)
 at com.edc.hrms.dao.impl.BaseDAOImpl.getSingleResultObject(BaseDAOImpl.java:158)
 at com.edc.hrms.dao.impl.AppraisalDAOImpl.getExpectedWorkingHours(AppraisalDAOImpl.java:307)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.getExpectedWorkingHours(AppraisalServiceImpl.java:440)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.getExtraWorkingHoursPoints(AppraisalServiceImpl.java:400)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.calculateExtraWorkingHoursPercentage(AppraisalServiceImpl.java:386)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.calculateUserBonus(AppraisalServiceImpl.java:365)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.calculateAppraisalSessionBonus(AppraisalServiceImpl.java:347)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.calculateAppraisalSessionResults(AppraisalServiceImpl.java:598)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy61.calculateAppraisalSessionResults(Unknown Source)
 at com.edc.hrms.view.controller.AppraisalEvaluationSessionFormController.performSessionStatusChangedAction(AppraisalEvaluationSessionFormController.java:93)
 at com.edc.hrms.view.controller.AppraisalEvaluationSessionFormController.onSubmit(AppraisalEvaluationSessionFormController.java:81)
 at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
 at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265)
 at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
 at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
 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.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:111)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
 at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
 at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:116)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.securechannel.ChannelProcessingFilter.doFilterHttp(ChannelProcessingFilter.java:116)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at com.randomcoder.security.DisableUrlSessionFilter.doFilter(DisableUrlSessionFilter.java:92)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 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:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Thread.java:619)
`

I've tried also using cast(count(o.id) as double) and it gave me another exception

javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query

and this is the full stack trace

javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
 at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
 at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:76)
 at com.edc.hrms.dao.impl.BaseDAOImpl.executeQuery(BaseDAOImpl.java:213)
 at com.edc.hrms.dao.impl.BaseDAOImpl.getSingleResultObject(BaseDAOImpl.java:158)
 at com.edc.hrms.dao.impl.AppraisalDAOImpl.getExpectedWorkingHours(AppraisalDAOImpl.java:307)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.getExpectedWorkingHours(AppraisalServiceImpl.java:440)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.getExtraWorkingHoursPoints(AppraisalServiceImpl.java:400)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.calculateExtraWorkingHoursPercentage(AppraisalServiceImpl.java:386)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.calculateUserBonus(AppraisalServiceImpl.java:365)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.calculateAppraisalSessionBonus(AppraisalServiceImpl.java:347)
 at com.edc.hrms.service.impl.AppraisalServiceImpl.calculateAppraisalSessionResults(AppraisalServiceImpl.java:598)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy61.calculateAppraisalSessionResults(Unknown Source)
 at com.edc.hrms.view.controller.AppraisalEvaluationSessionFormController.performSessionStatusChangedAction(AppraisalEvaluationSessionFormController.java:93)
 at com.edc.hrms.view.controller.AppraisalEvaluationSessionFormController.onSubmit(AppraisalEvaluationSessionFormController.java:81)
 at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
 at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265)
 at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
 at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
 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.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:111)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
 at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
 at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:116)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.securechannel.ChannelProcessingFilter.doFilterHttp(ChannelProcessingFilter.java:116)
 at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
 at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
 at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
 at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
 at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at com.randomcoder.security.DisableUrlSessionFilter.doFilter(DisableUrlSessionFilter.java:92)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 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:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
 at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
 at org.hibernate.loader.Loader.doList(Loader.java:2231)
 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
 at org.hibernate.loader.Loader.list(Loader.java:2120)
 at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
 at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
 at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
 at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
 at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)
 ... 88 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'double precision)-0.0)*540.0/60.0*0.85 as col_0_0_ from workingDayLog workingday' at line 1
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
 at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
 at com.mysql.jdbc.Util.getInstance(Util.java:381)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
 at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
 at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
 at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
 at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
 at org.hibernate.loader.Loader.doQuery(Loader.java:697)
 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
 at org.hibernate.loader.Loader.doList(Loader.java:2228)
 ... 96 more

and after I replaced count with constant double value it works fine then I tried another workaround

@NamedQuery(name="WorkingDayLog.getExpectedWorkingHours",query="select ((count(o.id)*1.0-:approvedVacs)*(:shiftDuration/60.0)*:factor) from WorkingDayLog o where o.workingDayDate between :appraisalStart and :appraisalEnd")

and it worked and the entity class looks like this

@Entity
@Table(name="workingDayLog")
public class WorkingDayLog extends BaseEntity{
 @Id
 @GeneratedValue(strategy=GenerationType.IDENTITY)
 private Long id;

 @Column
 @Temporal(TemporalType.DATE)
 private Date workingDayDate;

 public WorkingDayLog() {
 }
 public WorkingDayLog(Date todayDate) {
  this.workingDayDate=todayDate;
 }
 public Long getId() {
  return id;
 }
 public void setId(Long id) {
  this.id = id;
 }
 public Date getWorkingDayDate() {
  return workingDayDate;
 }
 public void setWorkingDayDate(Date workingDayDate) {
  this.workingDayDate = workingDayDate;
 }
 @Override
 public Object getEntityId() {
  return id;
 }
}

so any explanation
and another decent solution rather than this workaround?