This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes query on Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "query on Hibernate" Watch "query on Hibernate" New topic
Author

query on Hibernate

Ashok Kumar Chaganti
Greenhorn

Joined: Dec 25, 2006
Posts: 5
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

Joined: Jul 20, 2005
Posts: 9924
    
158

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?


[My Blog] [JavaRanch Journal]
Ashok Kumar Chaganti
Greenhorn

Joined: Dec 25, 2006
Posts: 5
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

Joined: Jul 20, 2005
Posts: 9924
    
158

Post the hibernate/Contact.hbm.xml file
Ashok Kumar Chaganti
Greenhorn

Joined: Dec 25, 2006
Posts: 5
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

Joined: Jul 20, 2005
Posts: 9924
    
158



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

Joined: Dec 25, 2006
Posts: 5
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
 
 
subject: query on Hibernate
 
Similar Threads
File Download Problem
Java Serializable on Servlets
jdbc + max(field)
max(field)
query on Hibernate