-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem in Fetching Data from Table
PostPosted: Wed Jun 13, 2007 8:20 am 
Newbie

Joined: Tue Jun 12, 2007 7:01 am
Posts: 2
Location: INDIA
Hi Frens,

I am writing a program to get the rows of a table named Users. Here is the code:
Session session=HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();

List results = session.createQuery("from Users").list();
System.out.println(results.size());

When i run it using build.xml, the following error is coming:
[java] [INFO] SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
[java] After the begin transaction
[java] [INFO] SettingsFactory - Echoing all SQL to stdout
[java] [INFO] SettingsFactory - Statistics: disabled
[java] [INFO] SettingsFactory - Deleted entity synthetic identifier rollback: disabled
[java] [INFO] SettingsFactory - Default entity-mode: pojo
[java] [INFO] SessionFactoryImpl - building session factory
[java] [INFO] SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured

[java] java.lang.reflect.UndeclaredThrowableException
[java] at $Proxy0.createQuery(Unknown Source)
[java] at SelectDemo.main(Unknown Source)
[java] Caused by: java.lang.reflect.InvocationTargetException
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContex
.java:292)
[java] ... 2 more
[java] Caused by: java.lang.NoClassDefFoundError: antlr/ANTLRException
[java] at org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:31)
[java] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:72)
[java] at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
[java] at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
[java] at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
[java] at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
[java] at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1600)
[java] ... 7 more

Can somebody tell me what could be the problem. If remove the
List results = session.createQuery("from Users").list();
System.out.println(results.size());

Then upto message it is coming alright.

Thanks for you reply...

_________________
Regards:

Ashish Mishra
"Work Hard, Party Harder.."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 9:09 am 
Newbie

Joined: Fri May 18, 2007 4:38 pm
Posts: 3
Location: phoenix
Can you please also post the mapping file for Users. and the hibernate config file, where this user class is registered


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 10:02 am 
Newbie

Joined: Tue May 29, 2007 12:33 am
Posts: 13
Any chance this might be classpath related?

Code:
Caused by: java.lang.NoClassDefFoundError: antlr/ANTLRException


That class is found in antlr*.jar, so first check if it is in classpath to discard classpath problems.

Cheers


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

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.