Hi All,
I am using Hibernate3.2,MySql 4.14 and Tomcat server for my application.
under Lib directory i have placed following jar files..
-------------------------------------------------------------
hibernate3.jar,jta.jar,antlr-2.7.6.jar,asm.jar,asm-attrs.jar,cglib-2.1.3.jar,commons-collections-2.1.1.jar,commons-logging-1.0.4.jar,dom4j-1.6.1.jar,log4j-1.2.11.jar
-------------------------------------------------------------------
Here is My program
-------------------
code:
--------------------------------------------------------------------------------
import org.hibernate.*;
import org.hibernate.Session;
import org.hibernate.cfg.*;
import java.util.*;
public class SelectHQLExample { public static void main(String[] args) {
Session session = null; try{
// This step will read hibernate.cfg.xml and prepare hibernate for use SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
//Using from Clause
String SQL_QUERY ="from Insurance";
Query query = session.createQuery(SQL_QUERY);
for(Iterator it=query.iterate();it.hasNext()
{ Insurance insurance=(Insurance)it.next(); System.out.println("ID: " + insurance.getLngInsuranceId()); System.out.println("First Name: " + insurance.getInsuranceName());
}
session.close(); }
catch(Exception e){ System.out.println(e.getMessage()); }
finally{ }
}
}
--------------------------------------------------------------------------------
---------------------------------------
When i run the above program the following error i am getting,please help to solve this issue..
----------------------------------------
Exception in thread "main" java.lang.NoSuchFieldError: tokenTypeToASTClassMap
at org.hibernate.hql.antlr.HqlBaseParser.buildTokenTypeASTClassMap(HqlBaseParser.java:4559)
at org.hibernate.hql.antlr.HqlBaseParser.<init>(HqlBaseParser.java:116)
at org.hibernate.hql.antlr.HqlBaseParser.<init>(HqlBaseParser.java:121)
at org.hibernate.hql.ast.HqlParser.<init>(HqlParser.java:49)
at org.hibernate.hql.ast.HqlParser.getInstance(HqlParser.java:45)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:242)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at SelectHQLExample.main(SelectHQLExample.java:20)
---------------------------------
Thanks
|