File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

query on Hibernate

 
Ashok Kumar Chaganti
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing the problem when i am trying to fetch the data from database using stored procedure and we are using oracle as a database.

i am posting my error below. please check the error and give me a solution ASAP. it's urgent for me....


Dec 26, 2006 11:43:29 AM org.hibernate.impl.SessionFactoryObjectFactory addInsta
nce
INFO: Not binding factory to JNDI, no JNDI name configured
Dec 26, 2006 11:43:29 AM org.hibernate.impl.SessionFactoryImpl <init>
SEVERE: Error in named query: selectAllEmployees_SP
org.hibernate.MappingException: Unknown entity: hibernate.Contact
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFacto
ryImpl.java:514)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.getSQLLoadable(SQ
LQueryReturnProcessor.java:53)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.processRootReturn
(SQLQueryReturnProcessor.java:119)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.processReturn(SQL
QueryReturnProcessor.java:98)
at org.hibernate.loader.custom.SQLQueryReturnProcessor.process(SQLQueryR
eturnProcessor.java:87)
at org.hibernate.loader.custom.SQLCustomQuery.<init>(SQLCustomQuery.java
:105)
at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPl
an.java:20)
at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(Query
PlanCache.java:113)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactor
yImpl.java:410)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
328)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1176)
at org.apache.jsp.test_jsp._jspService(test_jsp.java:59)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
at java.lang.Thread.run(Unknown Source)
org.hibernate.HibernateException: Errors in named queries: selectAllEmployees_SP

at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
339)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1176)
at org.apache.jsp.test_jsp._jspService(test_jsp.java:59)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
at java.lang.Thread.run(Unknown Source)
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SEVERE: Error in named query: selectAllEmployees_SP
org.hibernate.MappingException: Unknown entity: hibernate.Contact


You are using an entity(hibernate.Contact) in the query which is not mapped. Do you have a mapping file for this hibernate.Contact and also have you mentioned this mapping file in the hibernate.cfg.xml?
 
Ashok Kumar Chaganti
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please check the code


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<sql-query name="selectAllEmployees_SP" callable="true">
<return alias="contact" class="hibernate.Contact">
<return-property name="ename" column="name"/>
</return>
{ call apps.TEST1(?) }
</sql-query>
</hibernate-mapping>


<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:/comp/env/jdbc/matrics</property>
<property name="show_sql">false</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- Mapping files -->
<mapping resource="hibernate/Contact.hbm.xml"/>
</session-factory>
</hibernate-configuration>
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the hibernate/Contact.hbm.xml file
 
Ashok Kumar Chaganti
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hibernate/Contact.hbm.xml
----------------------------


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<sql-query name="selectAllEmployees_SP" callable="true">
<return alias="contact" class="hibernate.Contact">
<return-property name="ename" column="name"/>
</return>
{ call apps.TEST1(?) }
</sql-query>
</hibernate-mapping>
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The class hibernate.Contact is NOT mapped to any table through the mapping files. That's the reason you are seeing that error. You will have to map that class to some table through the mapping file.
 
Ashok Kumar Chaganti
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks a lot. But i am calling stored procedure using Hibernate. I am not mapping to any table..

please help me on this...

This is my procedure


CREATE OR REPLACE procedure TEST1(projectName OUT varchar) as
BEGIN
select name into projectName from pa_projects_all where project_id = 80;
END;
/


Thanks&Regards
Ashok Kumar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic