Spring4 is used as dependency Injection, the following code wrote for my sql db public List<Edi204DrayPortal> findbyHasDrayPortalStatusLimit(DataTablesReqRto criterias) { try{ int start = criterias.getStart(); int length = criterias.getLength(); // Global search string String searchValue = criterias.getSearch().getValue(); List<Order> orderValues = criterias.getOrder(); List<Columns> colIds = criterias.getColumns(); Query query = em.createNativeQuery( " select user, apptment, dnum, ln, vendorid, city, coalesce(d.destin, '-ERR PHONE IT-') as rt " + ", ramp " + ", if(rail is NULL ,'N', 'Y') as rail " + ", portalstatus " + ", st " + ", sentvia " + ", coalesce(d.state, '-ERR PHONE IT-') as rtstate " + " from ( " + " select if(e.dnum = 1, 'Pickup', 'Delivery') as dnum " + " , e.ln, e.user, e.vendorid, e.portalstatus " + " , if(e.dnum = 1, date_format(a.apptment,'%Y-%m-%d %H:%i'), date_format(ad.cnapptment,'%Y-%m-%d %H:%i')) as apptment " + " , if(e.dnum = 1, a.shipst, a.constt) as st " + " , if(e.dnum = 1, a.shipcity, a.concity) as city " + " , if(e.dnum = 1, ad.orig1rp, ad.dest1rp) as ramp " + " , coalesce(rb1.sentvia, '-NONE-') as sentvia " + " , rb1.rail " + " , ad.cnunicomp, ad.cnunitel " + " from edi204dray e " + " join armast a on a.ln = e.ln " + " join additional ad on ad.ln = e.ln " + " left join edirailbill rb1 on rb1.ln = e.ln and rb1.recno = (select max(rb2.recno) from edirailbill rb2 where rb2.ln = rb1.ln) " + " where e.recno = (select max(ee.recno) from edi204dray ee where ee.ln = e.ln and ee.dnum = e.dnum) " + appendSearch(colIds, searchValue) + " and portalstatus is not null " + " and not ((portalstatus = 'Ingate' or portalstatus = 'Ingate Empty/Street Turn') and DATEDIFF( NOW(), ackdate) > 1) " + " order by " + appendOrder(orderValues, colIds) + " limit (?1),(?2) " + " ) t " + " left join dest d on substring(d.destin,1,25) = t.cnunicomp and d.phone = t.cnunitel " , "CSRDashBoardMapping"); return query.setParameter(1, start) .setParameter(2, length) .getResultList(); }catch(Exception exp) { exp.printStackTrace(); } return null ; } Expectation: the code must find the parameter (?1), (?2) Other place for Error: add parameter at the end of red where just before closing the ) like and e.dnum= ?1 , e.dnum= :dNumVal, e.dnum= (?1), or e.dnum=? none of this work in this version, all of it work on version 5.0 the following is the stack trace this code was working fine in hibernate v5 until we upgrade we start get the following exception I try ?, ?1, and (?1) to add the parameter to the query non of them work on hibernate 5.1, any help from you will be highly appreciated. 11:47:41,593 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/dray-1.0.0-SNAPSHOT].[com.celticintl.dray]] (http-/127.0.0.1:8080-5) JBWEB000236: Servlet.service() for servlet com.celticintl.dray threw exception: java.lang.IllegalArgumentException: Parameter with that position [1] did not exist at org.hibernate.jpa.spi.BaseQueryImpl.findParameterRegistration(BaseQueryImpl.java:501) [hibernate-entitymanager-5.1.0-20160111.170655-128.jar:5.1.0.SNAPSHOT] at org.hibernate.jpa.spi.BaseQueryImpl.setParameter(BaseQueryImpl.java:691) [hibernate-entitymanager-5.1.0-20160111.170655-128.jar:5.1.0.SNAPSHOT] at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:181) [hibernate-entitymanager-5.1.0-20160111.170655-128.jar:5.1.0.SNAPSHOT] at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:32) [hibernate-entitymanager-5.1.0-20160111.170655-128.jar:5.1.0.SNAPSHOT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_79] at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_79] at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:360) [spring-orm-4.1.1.RELEASE.jar:4.1.1.RELEASE] at com.sun.proxy.$Proxy177.setParameter(Unknown Source) at com.celticintl.dray.dto.Edi204DrayPortal.findbyHasDrayPortalStatusLimit(Edi204DrayPortal.java:224) [classes:] at com.celticintl.dray.controller.OrderMonitorDashBoardControllerRest.getDataTableInfo(OrderMonitorDashBoardControllerRest.java:34) [classes:] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_79] at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_79] at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) [spring-web-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) [spring-web-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) [spring-webmvc-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:781) [spring-webmvc-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:721) [spring-webmvc-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) [spring-webmvc-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) [spring-webmvc-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) [spring-webmvc-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) [spring-webmvc-4.1.1.RELEASE.jar:4.1.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.1.RELEASE.jar:4.1.1.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at com.celticintl.dray.filters.TenantIdentifierFilter.doFilter(TenantIdentifierFilter.java:80) [classes:] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) [spring-web-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) [spring-web-4.1.1.RELEASE.jar:4.1.1.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:208) [cors-filter-2.4.jar:2.4] at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:274) [cors-filter-2.4.jar:2.4] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4] at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_79] |