-->
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.  [ 6 posts ] 
Author Message
 Post subject: Multiparameter SQL functions vs. the new parser
PostPosted: Sun May 29, 2005 11:11 am 
Newbie

Joined: Sat Dec 11, 2004 12:19 pm
Posts: 3
Hi,

I have a problem calling SQL functions from HQL, when using the new parser. Any help is welcome, thanks.

It seems that it is a problem of multiparameter queries only.

This worked well with the old parser:

Code:
...
in MyCustomSQLServerDialect, constructor:
registerFunction( "left", new StandardSQLFunction( "left", Hibernate.STRING) );
...
select  left(areal.nazov,3) from Areal areal
...


With the new parser it causes parsing errors.

Hibernate version:
3.0.5

Mapping documents:

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

Full stack trace of any exception that occurs:
org.hibernate.hql.ast.QuerySyntaxError: unexpected token: left near line 1, column 9 [select left(areal.nazov,3) from sk.spp.eis.beans.Areal areal]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:215)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at sk.spp.eis.dev.StandaloneGUIHibernateTest.actionOK(StandaloneGUIHibernateTest.java:206)
at sk.spp.eis.dev.StandaloneGUIHibernateTest.actionPerformed(StandaloneGUIHibernateTest.java:161)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: line 1:9: unexpected token: left
at org.hibernate.hql.antlr.HqlBaseParser.selectClause(HqlBaseParser.java:962)
at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:735)
at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:611)
at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:263)
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:150)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:209)
... 18 more

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Code:


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 29, 2005 11:13 am 
Newbie

Joined: Sat Dec 11, 2004 12:19 pm
Posts: 3
Sorry,

"It seems that it is a problem of multiparameter queries only. "

was supposed to be

"It seems that it is a problem of multiparameter functions only. "


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 29, 2005 12:19 pm 
Regular
Regular

Joined: Tue May 24, 2005 10:19 am
Posts: 65
it is necessary to override some methods, see post
http://forum.hibernate.org/viewtopic.php?t=942418&highlight=


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 30, 2005 3:18 am 
Newbie

Joined: Sat Dec 11, 2004 12:19 pm
Posts: 3
zesj:

I saw the other post before, but it only reports problems, not a solution. I also tried to implement custom StandardSQLFunction subclass for this, but it did not work either.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 30, 2005 9:38 am 
Regular
Regular

Joined: Tue May 24, 2005 10:19 am
Posts: 65
i make more tests. please wait.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 30, 2005 11:39 am 
Regular
Regular

Joined: Tue May 24, 2005 10:19 am
Posts: 65
try use SQLFunctionTemplate


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