-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Errors in Named Query
PostPosted: Mon Jan 15, 2007 6:43 am 
Beginner
Beginner

Joined: Thu Mar 24, 2005 6:29 am
Posts: 24
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.2.0

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="patni.sample">
<sql-query name="test3">
SELECT ENAME AS {emp1.name}FROM employees
<return alias="emp1" class="EmployeeVO" entity-name=""/>
</sql-query>
</hibernate-mapping>


SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
System.out.println("Done2");
session =sessionFactory.openSession();
System.out.println("Done3");
session.beginTransaction();
List alist = session.getNamedQuery("test3").list();
// System.out.println("The no : of Users-->"+alist.size());

System.out.println("Done");


WARN SessionFactoryObjectFactory:98 - Could not bind factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.getNameParser(InitialContext.java:429)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:306)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
at Test.main(Test.java:27)
16:27:45,045 DEBUG SessionFactoryImpl:308 - instantiated session factory
16:27:45,045 DEBUG SessionFactoryImpl:390 - Checking 0 named HQL queries
16:27:45,045 DEBUG SessionFactoryImpl:410 - Checking 1 named SQL queries
16:27:45,045 DEBUG SessionFactoryImpl:418 - Checking named SQL query: test3
16:27:45,060 DEBUG QueryPlanCache:112 - unable to locate native-sql query plan in cache; generating (SELECT ENAME AS {emp1.name}FROM employees)
16:27:45,060 DEBUG SQLCustomQuery:62 - starting processing of sql query [SELECT ENAME AS {emp1.name}FROM employees]
16:27:45,107 ERROR SessionFactoryImpl:362 - Error in named query: test3
org.hibernate.MappingException: Unknown entity:
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:548)
at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.getSQLLoadable(SQLQueryReturnProcessor.java:312)
at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processRootReturn(SQLQueryReturnProcessor.java:353)
at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processReturn(SQLQueryReturnProcessor.java:332)
at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.process(SQLQueryReturnProcessor.java:148)
at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:64)
at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:43)
at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:114)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:444)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:351)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
at Test.main(Test.java:27)
org.hibernate.HibernateException: Errors in named queries: test3
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:364)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1291)
at Test.main(Test.java:27)
java.lang.NullPointerException
at Test.main(Test.java:41):


oracle 9i:


My POJO is here

public class EmployeeVO implements Serializable{

private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public EmployeeVO() {
super();
// TODO Auto-generated constructor stub
}
}



I am trying to call a named query



Thanks in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.