sql server - Getting java.sql.SQLException: Invalid column name with hibernate -


getting java.sql.sqlexception: invalid column name though column same name in table. can reason?

trying call sp below code:

 session session = hibernateutil.getsessionfactory().opensession();             query query = session.getnamedquery("employee.prc_hb_emp_sp1");                     query.setparameter("in_empid", empid);                list<employee> emplist = query.list();               system.out.println(emplist); 

entity class employee:

    @entity     @table(name = "employee")     //@org.hibernate.annotations.namednativequery(name = "employee.prc_hb_emp_sp1", query = "call prc_hb_emp_sp1(?,:in_empid)", callable = true, resultclass = employee.class)     @org.hibernate.annotations.namednativequery(name = "employee.prc_hb_emp_sp1", query = "call prc_hb_emp_sp1(?,:in_empid)", callable = true, resultclass = employee.class)      public class employee implements serializable {     private static final long serialversionuid = -723583058586873479l;     @id     @column(name = "empid")     private integer empid;     @column(name = "empname")     private string empname;     @column(name = "address")     private string empaddress;     @column(name = "salary")     private long salary;     @column(name = "empage")     private integer empage; ............ } 

here sp:

create or replace procedure prc_hb_emp_sp1 (   out_value out sys_refcursor,   in_empid  number )  begin     open out_value     select empid,empname              employee      empid = in_empid;  end prc_hb_emp_sp1; 

stacktrace:

severe: servlet.service() servlet [sdnext] in context path [/sdnext] threw exception [request processing failed; nested exception org.hibernate.exception.genericjdbcexception: not execute query] root cause java.sql.sqlexception: invalid column name     @ oracle.jdbc.dbaccess.dberror.throwsqlexception(dberror.java:134)     @ oracle.jdbc.dbaccess.dberror.throwsqlexception(dberror.java:179)     @ oracle.jdbc.dbaccess.dberror.throwsqlexception(dberror.java:269)     @ oracle.jdbc.driver.oraclestatement.get_column_index(oraclestatement.java:5971)     @ oracle.jdbc.driver.oracleresultsetimpl.findcolumn(oracleresultsetimpl.java:1527)     @ oracle.jdbc.driver.oracleresultset.getstring(oracleresultset.java:1482)     @ org.hibernate.type.stringtype.get(stringtype.java:18)     @ org.hibernate.type.nullabletype.nullsafeget(nullabletype.java:163)     @ org.hibernate.type.nullabletype.nullsafeget(nullabletype.java:154)     @ org.hibernate.type.abstracttype.hydrate(abstracttype.java:81)     @ org.hibernate.persister.entity.abstractentitypersister.hydrate(abstractentitypersister.java:2101)     @ org.hibernate.loader.loader.loadfromresultset(loader.java:1380)     @ org.hibernate.loader.loader.instancenotyetloaded(loader.java:1308)     @ org.hibernate.loader.loader.getrow(loader.java:1206)     @ org.hibernate.loader.loader.getrowfromresultset(loader.java:580)     @ org.hibernate.loader.loader.doquery(loader.java:701)     @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:236)     @ org.hibernate.loader.loader.dolist(loader.java:2213)     @ org.hibernate.loader.loader.listignorequerycache(loader.java:2104)     @ org.hibernate.loader.loader.list(loader.java:2099)     @ org.hibernate.loader.custom.customloader.list(customloader.java:289)     @ org.hibernate.impl.sessionimpl.listcustomquery(sessionimpl.java:1695)     @ org.hibernate.impl.abstractsessionimpl.list(abstractsessionimpl.java:142)     @ org.hibernate.impl.sqlqueryimpl.list(sqlqueryimpl.java:152)     @ com.dineshonjava.controller.employeecontroller.getemployeedetail(employeecontroller.java:160)     @ 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.web.bind.annotation.support.handlermethodinvoker.invokehandlermethod(handlermethodinvoker.java:176)     @ org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter.invokehandlermethod(annotationmethodhandleradapter.java:436)     @ org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter.handle(annotationmethodhandleradapter.java:424)     @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:923)     @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:852)     @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:882)     @ org.springframework.web.servlet.frameworkservlet.doget(frameworkservlet.java:778)     @ javax.servlet.http.httpservlet.service(httpservlet.java:620)     @ 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.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:503)     @ 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:1070)     @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:611)     @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:316)     @ 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) 

your mappings contain columns address,salary , empage missing sp.you need include in statement.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -