-->
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.  [ 9 posts ] 
Author Message
 Post subject: antlr/RecognitionException
PostPosted: Tue Mar 21, 2006 1:45 pm 
Newbie

Joined: Tue Mar 07, 2006 3:57 pm
Posts: 10
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I am getting RecognitionException, when executing a Named Query in Hibernate3.0.5.
When I run the same sample with Hibernate 3.1, I get no such exception.

I have included antlr-2.7.5.jar in my classpath, but it doesnt seem to work at all.


This is my query :

<query name="AUDITPK">
SELECT AUDIT_PK_SEQ.NEXTVAL FROM DUAL
</query>


This is the stacktrace :

java.lang.NoClassDefFoundError: antlr/RecognitionException
at org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:27)
at org.hibernate.impl.SessionFactoryImpl.createQueryTranslators(SessionFactoryImpl.java:357)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:423)
at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:388)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:291)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at com.jpmchase.pws.util.hibernate.HibernateSessionUtil.initSessionFactory(HibernateSessionUtil.java:49)
at com.jpmchase.pws.util.hibernate.HibernateSessionUtil.getSessionFactory(HibernateSessionUti


Thanks in advance,
Pooja

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Hibernate Gurus
PostPosted: Tue Mar 21, 2006 2:55 pm 
Newbie

Joined: Tue Mar 07, 2006 3:57 pm
Posts: 10
Hibernate Gurus... Please Suggest...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 4:27 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
pooja -

I may not be the hibernate Guru you are looking for, but here is my take on your problem:

Obviously it has to be a class loading problem (to resolve the antlr/RecognitionException) - so check your classpath - make sure you are pointing to <hib3.0.5>/lib for all the supporting libs. if still an issue then this means that something was upgrade in 3.1 and this not supported in 3.0.5.

Having said that - the problem you are experiencing with the named query may be due to not being able to figure out how to parse the query. Are you going against the same database, using the same Dialiect (from hibernate.properties)...
(The select you are giving is Oracle syntax for getting sequences.)

and/or did you try it with SQL-QUERY, ie:

<sql-query name="GETPK">
SELECT hibernate_SEQuence.NEXTVAL FROM DUAL
</sql-query>

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 5:38 pm 
Newbie

Joined: Tue Mar 07, 2006 3:57 pm
Posts: 10
Thanks jt

Yes I am using the same database..
Its Oracle 9i

and dialect is :
<property
name="dialect">org.hibernate.dialect.Oracle9Dialect</property>


I tried using <sql-query>, but on startup it does'nt recognize any named queries,
Simply prints out a message, Checking 0 Named Queries.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 5:42 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
put your <sql-query in one of your Entity mappings after the class decl. ie:

...
</class>
<sql-query name="GETPK">
SELECT hibernate_SEQuence.NEXTVAL FROM DUAL
</sql-query>
</hibernate-mapping>

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 5:53 pm 
Newbie

Joined: Tue Mar 07, 2006 3:57 pm
Posts: 10
Works with antlr-2.7.6rc1.jar.

However throws an error - *** ERROR: DUAL is not mapped.

Do I really need to map DUAL ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 5:55 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
using the <sql-query will fix that problem

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 6:03 pm 
Newbie

Joined: Tue Mar 07, 2006 3:57 pm
Posts: 10
This is the structure in my hbm

</class>
<query name="AUDITPK">
SELECT AUDIT_PK_SEQ.NEXTVAL FROM DUAL
</query>
</hibernate-mapping>



The <sql-query> works great with Hibernate 3.1, but fails with 3.0.5


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 6:46 pm 
Expert
Expert

Joined: Mon Jan 09, 2006 5:01 pm
Posts: 311
Location: Sacramento, CA
go to google and type in
"astquerytranslator"

the first link is to a bug in 3.0.3 may be related to what you are doing
and there are a few other links following that may help.

_________________
-JT

If you find my replies helpful, please rate by clicking 'Y' on them. I appreciate it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.