mysql - org.hibernate.MappingException: Named query not known -


please me find out issue.i beginner in spring hibernate , using spring 3 , hibernate 4 in project, want use namedquery in application. have created named query fetch data multiple table using join, getting issue please correct me if doing wrong here. vode below entity class:-

@embeddable    @namedquery(     name = "findallproduct",      query = "select pvpol.pincode,po.description"      +" product_vendor_payment_option_location pvpol"      +" inner join pvpol.payement_id pid"      +" inner join pvpol.pincode pc"     +" inner join pvpol.paymentoptions po"     +" pvpol.id = :payement_id"     )    public class product_vendor_payment_option_location extends entity {       @column(name="id")     @onetomany(cascade=cascadetype.all,fetch=fetchtype.eager,mappedby="id")     private collection<product_catalog_vendor> payement_id;       @column(name="pincode_id")     @onetomany(cascade=cascadetype.all,fetch=fetchtype.eager,mappedby="pincode_id")     private collection<pincodes> pincode;      @column(name = "payment_options")     @onetomany(cascade=cascadetype.all,fetch=fetchtype.eager,mappedby="payment_options")     private set<payment_options> paymentoptions;  //getters , setters here   } 

these tables want fetch data:-

    create table product_vendor_payment_option_location (   id integer unsigned  not null   auto_increment,   payment_id integer unsigned  not null  ,      pincode_id integer unsigned  not null  ,   payment_options integer unsigned not null ,    primary key(id,payment_id, pincode_id)  ,  index product_vendor_payment_option_location_fkindex1(payment_options), index product_vendor_payment_option_location_fkindex2(payment_id)  , index product_vendor_payment_option_location_fkindex3(pincode_id),   foreign key(payment_options)      references payement_options(payment_options)       on delete no action       on update no action,   foreign key(payment_id)     references product_catalog_vendor(id)       on delete no action       on update no action,   foreign key(pincode_id)     references pincodes(pincode_id)       on delete no action       on update no action);   create table payement_options ( payment_options integer unsigned  not null   auto_increment, description varchar(500)  null    , primary key(payment_options));   create table product_catalog_vendor (   id integer unsigned  not null  ,  prefilled_response_id integer unsigned  null  ,   product_catalog_id integer unsigned  not null  ,  user_id integer unsigned  not null  ,   aud_create_time timestamp  not null  ,  aud_update_time timestamp  not null    , primary key(id)  ,index product_catalog_vendor_fkindex1(product_catalog_id)  , index product_catalog_vendor_fkindex2(user_id)  ,index product_catalog_vendor_fkindex3(prefilled_response_id),  foreign key(product_catalog_id)     references product_catalog(product_catalog_id)       on delete cascade       on update no action,  foreign key(user_id)    references vendor(user_id)       on delete cascade      on update no action,  foreign key(prefilled_response_id)     references prefilled_response(prefilled_response_id)      on delete no action       on update no action);   create table pincodes ( pincode_id integer unsigned  not null auto_increment, pincode integer unsigned not null,    description integer unsigned  null, primary key(pincode_id)); 

in dao class calling namedquery through:-

session session = sessionfactory.getcurrentsession(); query query=(query) session.getnamedquery("findallproduct"); 

when running after deployement , getting below error in logs:-

10:27:36,139 info  [org.springframework.web.servlet.mvc.annotation.defaultannotationhandlermapping] (msc service thread 1-2) root mapping handler 'productcontroller' 10:27:36,626 info  [org.springframework.web.servlet.dispatcherservlet] (msc service thread 1-2) frameworkservlet 'product': initialization completed in 3979 ms 10:27:36,633 info  [org.jboss.web] (msc service thread 1-2) registering web context: /usermanagement 10:27:36,636 info  [org.jboss.as] (msc service thread 1-4) jboss 7.0.2.final "arc" started in 8346ms - started 182 of 239 services (57 services passive or on-demand) 10:27:36,670 info  [org.jboss.as.server.controller] (deploymentscanner-threads - 2) deployed "usermanagement.war" 10:27:52,987 error [org.apache.catalina.core.containerbase.[jboss.web].[default-host].[/usermanagement].[product]] (http--127.0.0.1-8080-1) servlet.service() servlet product threw exception: org.hibernate.mappingexception: named query not known: findallproduct     @ org.hibernate.internal.abstractsessionimpl.getnamedquery(abstractsessionimpl.java:154) [hibernate-core-4.1.10.final.jar:]     @ org.hibernate.internal.sessionimpl.getnamedquery(sessionimpl.java:1343) [hibernate-core-4.1.10.final.jar:]     @ com.ecom.data.access.product.productdaoimpl.getallproduct(productdaoimpl.java:36) [classes:]     @ com.ecom.data.access.transaction.productserviceimpl.getallproduct(productserviceimpl.java:30) [classes:]     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) [:1.6.0_43]     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) [:1.6.0_43]     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) [:1.6.0_43]     @ java.lang.reflect.method.invoke(method.java:597) [:1.6.0_43]     @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) [spring-aop-3.2.2.release.jar:]     @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:183) [spring-aop-3.2.2.release.jar:]     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:150) [spring-aop-3.2.2.release.jar:]     @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:96) [spring-tx-3.2.2.release.jar:]     @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:260) [spring-tx-3.2.2.release.jar:]     @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:94) [spring-tx-3.2.2.release.jar:]     @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) [spring-aop-3.2.2.release.jar:]     @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:204) [spring-aop-3.2.2.release.jar:]     @ com.sun.proxy.$proxy35.getallproduct(unknown source)     @ com.ecom.data.access.controller.productcontroller.listproducts(productcontroller.java:24) [classes:]     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) [:1.6.0_43]     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) [:1.6.0_43]     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) [:1.6.0_43]     @ java.lang.reflect.method.invoke(method.java:597) [:1.6.0_43]     @ org.springframework.web.bind.annotation.support.handlermethodinvoker.invokehandlermethod(handlermethodinvoker.java:176) [spring-web-3.2.2.release.jar:]     @ org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter.invokehandlermethod(annotationmethodhandleradapter.java:440) [spring-webmvc-3.2.2.release.jar:]     @ org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter.handle(annotationmethodhandleradapter.java:428) [spring-webmvc-3.2.2.release.jar:]     @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:925) [spring-webmvc-3.2.2.release.jar:]     @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:856) [spring-webmvc-3.2.2.release.jar:]     @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:936) [spring-webmvc-3.2.2.release.jar:]     @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:827) [spring-webmvc-3.2.2.release.jar:]     @ javax.servlet.http.httpservlet.service(httpservlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.final.jar:1.0.0.final]     @ org.springframework.web.servlet.frameworkservlet.service(frameworkservlet.java:812) [spring-webmvc-3.2.2.release.jar:]     @ javax.servlet.http.httpservlet.service(httpservlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.final.jar:1.0.0.final]     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:329) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:248) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:275) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:161) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.jboss.as.web.security.securitycontextassociationvalve.invoke(securitycontextassociationvalve.java:139) [jboss-as-web-7.0.2.final.jar:7.0.2.final]     @ org.jboss.as.web.namingvalve.invoke(namingvalve.java:57) [jboss-as-web-7.0.2.final.jar:7.0.2.final]     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:154) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:362) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.apache.coyote.http11.http11processor.process(http11processor.java:877) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:667) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:952) [jbossweb-7.0.1.final.jar:7.0.2.final]     @ java.lang.thread.run(thread.java:662) [:1.6.0_43] 

looking forward suggestions...

i suppose should put @namedquery on entity (where have @entity not @embeddable).

read here: http://docs.oracle.com/javaee/6/api/javax/persistence/namedquery.html


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -