mysql - Exception in Hibernate Query- java.lang.IllegalArgumentException -


i have written sql query working fine when execute in mysql workbench. same query trying implement in hibernate query use in java code giving exception. please check , me

sql query

select m.* ct_group_master m m.is_public='y' or m.admin_approved='y' , m.company_id = 1 union select g.* ct_group_master g g.is_private='y' , g.group_id in (select group_id ct_group_member_mapping g.group_id=group_id , member_id = 2)

hibernate query java interface method

@query("select m ctxtgroupmaster m m.ispublic='y' or m.adminapproved='y' , m.companymaster.companyid=?1 , m.isactive=?3 union select g ctxtgroupmaster g g.isprivate='y' , "         + "g.groupid in(select gm.groupmaster.groupid ctxtgroupmembermapping gm g.groupid=gm.groupmaster.groupid , gm.receiverconfig.receiverconfigid=?2)") list<ctxtgroupmaster> findbycompanyidandreceiverconfigidandisactive(integer companyid,integer receiverconfigid,string isactive);   

error log

severe: exception sending context initialized event listener instance of class org.springframework.web.context.contextloaderlistener org.springframework.beans.factory.beancreationexception: error creating bean name 'ctxtgroupmasterdao': invocation of init method failed; nested exception java.lang.illegalargumentexception: validation failed query method public abstract java.util.list com.acinfotech.crowdtxt.jpa.dao.ctxtgroupmasterdao.findbycompanyidandreceiverconfigidandisactive(java.lang.integer,java.lang.integer,java.lang.string)!     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1512)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:521)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:458)     @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:296)     @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:223)     @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:293)     @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:194)     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:610)     @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:932)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:479)     @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:389)     @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:294)     @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:112)     @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:5016)     @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5524)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1575)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1565)     @ java.util.concurrent.futuretask.run(futuretask.java:262)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)     @ java.lang.thread.run(thread.java:745) caused by: java.lang.illegalargumentexception: validation failed query method public abstract java.util.list com.acinfotech.crowdtxt.jpa.dao.ctxtgroupmasterdao.findbycompanyidandreceiverconfigidandisactive(java.lang.integer,java.lang.integer,java.lang.string)!     @ org.springframework.data.jpa.repository.query.simplejpaquery.validatequery(simplejpaquery.java:80)     @ org.springframework.data.jpa.repository.query.simplejpaquery.<init>(simplejpaquery.java:54)     @ org.springframework.data.jpa.repository.query.jpaqueryfactory.frommethodwithquerystring(jpaqueryfactory.java:65)     @ org.springframework.data.jpa.repository.query.jpaqueryfactory.fromqueryannotation(jpaqueryfactory.java:48)     @ org.springframework.data.jpa.repository.query.jpaquerylookupstrategy$declaredquerylookupstrategy.resolvequery(jpaquerylookupstrategy.java:115)     @ org.springframework.data.jpa.repository.query.jpaquerylookupstrategy$createifnotfoundquerylookupstrategy.resolvequery(jpaquerylookupstrategy.java:160)     @ org.springframework.data.jpa.repository.query.jpaquerylookupstrategy$abstractquerylookupstrategy.resolvequery(jpaquerylookupstrategy.java:69)     @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.<init>(repositoryfactorysupport.java:304)     @ org.springframework.data.repository.core.support.repositoryfactorysupport.getrepository(repositoryfactorysupport.java:161)     @ org.springframework.data.repository.core.support.repositoryfactorybeansupport.initandreturn(repositoryfactorybeansupport.java:224)     @ org.springframework.data.repository.core.support.repositoryfactorybeansupport.afterpropertiesset(repositoryfactorybeansupport.java:210)     @ org.springframework.data.jpa.repository.support.jparepositoryfactorybean.afterpropertiesset(jparepositoryfactorybean.java:84)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1571)     @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1509)     ... 21 more caused by: java.lang.nullpointerexception     @ org.hibernate.hql.internal.ast.parametertranslationsimpl.getnamedparameterexpectedtype(parametertranslationsimpl.java:92)     @ org.hibernate.engine.query.spi.hqlqueryplan.buildparametermetadata(hqlqueryplan.java:410)     @ org.hibernate.engine.query.spi.hqlqueryplan.<init>(hqlqueryplan.java:145)     @ org.hibernate.engine.query.spi.hqlqueryplan.<init>(hqlqueryplan.java:88)     @ org.hibernate.engine.query.spi.queryplancache.gethqlqueryplan(queryplancache.java:190)     @ org.hibernate.internal.abstractsessionimpl.gethqlqueryplan(abstractsessionimpl.java:301)     @ org.hibernate.internal.abstractsessionimpl.createquery(abstractsessionimpl.java:236)     @ org.hibernate.internal.sessionimpl.createquery(sessionimpl.java:1800)     @ org.hibernate.jpa.spi.abstractentitymanagerimpl.createquery(abstractentitymanagerimpl.java:328)     @ sun.reflect.generatedmethodaccessor41.invoke(unknown source)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ org.springframework.orm.jpa.extendedentitymanagercreator$extendedentitymanagerinvocationhandler.invoke(extendedentitymanagercreator.java:366)     @ com.sun.proxy.$proxy27.createquery(unknown source)     @ org.springframework.data.jpa.repository.query.simplejpaquery.validatequery(simplejpaquery.java:74)     ... 34 more   

new error log after running code

124752 [http-bio-7070-exec-7] warn  org.hibernate.engine.jdbc.spi.sqlexceptionhelper  - sql error: 1146, sqlstate: 42s02 124753 [http-bio-7070-exec-7] error org.hibernate.engine.jdbc.spi.sqlexceptionhelper  - table 'crowdtxt_dev.ctxtgroupmaster' doesn't exist 124763 [http-bio-7070-exec-7] info  com.acinfotech.crowdtxt.jpa.service.persistenceserviceimpl  - not extract resultset; sql [n/a]; nested exception org.hibernate.exception.sqlgrammarexception: not extract resultset org.springframework.dao.invaliddataaccessresourceusageexception: not extract resultset; sql [n/a]; nested exception org.hibernate.exception.sqlgrammarexception: not extract resultset     @ org.springframework.orm.hibernate3.sessionfactoryutils.converthibernateaccessexception(sessionfactoryutils.java:635)     @ org.springframework.orm.jpa.vendor.hibernatejpadialect.translateexceptionifpossible(hibernatejpadialect.java:106)     @ org.springframework.orm.jpa.abstractentitymanagerfactorybean.translateexceptionifpossible(abstractentitymanagerfactorybean.java:403)     @ org.springframework.dao.support.chainedpersistenceexceptiontranslator.translateexceptionifpossible(chainedpersistenceexceptiontranslator.java:58)     @ org.springframework.dao.support.dataaccessutils.translateifnecessary(dataaccessutils.java:213)     @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:163)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.data.jpa.repository.support.lockmoderepositorypostprocessor$lockmodepopulatingmethodintercceptor.invoke(lockmoderepositorypostprocessor.java:92)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.aop.interceptor.exposeinvocationinterceptor.invoke(exposeinvocationinterceptor.java:91)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:204)     @ com.sun.proxy.$proxy32.findbycompanyidandreceiverconfigidandisactive(unknown source)     @ com.acinfotech.crowdtxt.jpa.service.persistenceserviceimpl.getusergrouplist(persistenceserviceimpl.java:2455)     @ com.acinfotech.crowdtxt.service.restserviceimpl.getusergrouplist(restserviceimpl.java:439)     @ com.acinfotech.crowdtxt.service.maincontroller.getusergrouplist(maincontroller.java:2348)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ com.sun.jersey.spi.container.javamethodinvokerfactory$1.invoke(javamethodinvokerfactory.java:60)     @ com.sun.jersey.server.impl.model.method.dispatch.abstractresourcemethoddispatchprovider$responseoutinvoker._dispatch(abstractresourcemethoddispatchprovider.java:205)     @ com.sun.jersey.server.impl.model.method.dispatch.resourcejavamethoddispatcher.dispatch(resourcejavamethoddispatcher.java:75)     @ com.sun.jersey.server.impl.uri.rules.httpmethodrule.accept(httpmethodrule.java:302)     @ com.sun.jersey.server.impl.uri.rules.righthandpathrule.accept(righthandpathrule.java:147)     @ com.sun.jersey.server.impl.uri.rules.resourceclassrule.accept(resourceclassrule.java:108)     @ com.sun.jersey.server.impl.uri.rules.righthandpathrule.accept(righthandpathrule.java:147)     @ com.sun.jersey.server.impl.uri.rules.rootresourceclassesrule.accept(rootresourceclassesrule.java:84)     @ com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest(webapplicationimpl.java:1542)     @ com.sun.jersey.server.impl.application.webapplicationimpl._handlerequest(webapplicationimpl.java:1473)     @ com.sun.jersey.server.impl.application.webapplicationimpl.handlerequest(webapplicationimpl.java:1419)     @ com.sun.jersey.server.impl.application.webapplicationimpl.handlerequest(webapplicationimpl.java:1409)     @ com.sun.jersey.spi.container.servlet.webcomponent.service(webcomponent.java:409)     @ com.sun.jersey.spi.container.servlet.servletcontainer.service(servletcontainer.java:540)     @ com.sun.jersey.spi.container.servlet.servletcontainer.service(servletcontainer.java:715)     @ javax.servlet.http.httpservlet.service(httpservlet.java:727)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:303)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208)     @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:330)     @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.invoke(filtersecurityinterceptor.java:118)     @ org.springframework.security.web.access.intercept.filtersecurityinterceptor.dofilter(filtersecurityinterceptor.java:84)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.access.exceptiontranslationfilter.dofilter(exceptiontranslationfilter.java:113)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.authentication.anonymousauthenticationfilter.dofilter(anonymousauthenticationfilter.java:113)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.servletapi.securitycontextholderawarerequestfilter.dofilter(securitycontextholderawarerequestfilter.java:54)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ com.acinfotech.crowdtxt.secure.authenticationtokenprocessingfilter.dofilter(authenticationtokenprocessingfilter.java:55)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.authentication.preauth.abstractpreauthenticatedprocessingfilter.dofilter(abstractpreauthenticatedprocessingfilter.java:94)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:87)     @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:342)     @ org.springframework.security.web.filterchainproxy.dofilterinternal(filterchainproxy.java:192)     @ org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:160)     @ org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:343)     @ org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:260)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:241)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:208)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:220)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:122)     @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:504)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:170)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:103)     @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:950)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:116)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:421)     @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1074)     @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:611)     @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:314)     @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145)     @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615)     @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)     @ java.lang.thread.run(thread.java:745) caused by: org.hibernate.exception.sqlgrammarexception: not extract resultset     @ org.hibernate.exception.internal.sqlexceptiontypedelegate.convert(sqlexceptiontypedelegate.java:80)     @ org.hibernate.exception.internal.standardsqlexceptionconverter.convert(standardsqlexceptionconverter.java:49)     @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:126)     @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:112)     @ org.hibernate.engine.jdbc.internal.resultsetreturnimpl.extract(resultsetreturnimpl.java:89)     @ org.hibernate.loader.loader.getresultset(loader.java:2065)     @ org.hibernate.loader.loader.executequerystatement(loader.java:1862)     @ org.hibernate.loader.loader.executequerystatement(loader.java:1838)     @ org.hibernate.loader.loader.doquery(loader.java:909)     @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:354)     @ org.hibernate.loader.loader.dolist(loader.java:2553)     @ org.hibernate.loader.loader.dolist(loader.java:2539)     @ org.hibernate.loader.loader.listignorequerycache(loader.java:2369)     @ org.hibernate.loader.loader.list(loader.java:2364)     @ org.hibernate.loader.custom.customloader.list(customloader.java:353)     @ org.hibernate.internal.sessionimpl.listcustomquery(sessionimpl.java:1873)     @ org.hibernate.internal.abstractsessionimpl.list(abstractsessionimpl.java:311)     @ org.hibernate.internal.sqlqueryimpl.list(sqlqueryimpl.java:141)     @ org.hibernate.jpa.internal.queryimpl.list(queryimpl.java:573)     @ org.hibernate.jpa.internal.queryimpl.getresultlist(queryimpl.java:449)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:606)     @ org.springframework.orm.jpa.sharedentitymanagercreator$deferredqueryinvocationhandler.invoke(sharedentitymanagercreator.java:311)     @ com.sun.proxy.$proxy105.getresultlist(unknown source)     @ org.springframework.data.jpa.repository.query.jpaqueryexecution$collectionexecution.doexecute(jpaqueryexecution.java:96)     @ org.springframework.data.jpa.repository.query.jpaqueryexecution.execute(jpaqueryexecution.java:61)     @ org.springframework.data.jpa.repository.query.abstractjpaquery.doexecute(abstractjpaquery.java:96)     @ org.springframework.data.jpa.repository.query.abstractjpaquery.execute(abstractjpaquery.java:86)     @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.invoke(repositoryfactorysupport.java:337)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:110)     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172)     @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:155)     ... 72 more caused by: com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: table 'crowdtxt_dev.ctxtgroupmaster' doesn't exist     @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method)     @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57)     @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45)     @ java.lang.reflect.constructor.newinstance(constructor.java:526)     @ com.mysql.jdbc.util.handlenewinstance(util.java:411)     @ com.mysql.jdbc.util.getinstance(util.java:386)     @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:1054)     @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:4190)     @ com.mysql.jdbc.mysqlio.checkerrorpacket(mysqlio.java:4122)     @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:2570)     @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:2731)     @ com.mysql.jdbc.connectionimpl.execsql(connectionimpl.java:2818)     @ com.mysql.jdbc.preparedstatement.executeinternal(preparedstatement.java:2157)     @ com.mysql.jdbc.preparedstatement.executequery(preparedstatement.java:2324)     @ org.hibernate.engine.jdbc.internal.resultsetreturnimpl.extract(resultsetreturnimpl.java:80)     ... 102 more 

you need add @query annotation want run native sql query:

@query(value = "select ...your select....", nativequery = true) 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -