-->
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: ClasscQueryTranslator with SQL functions
PostPosted: Mon May 15, 2006 7:04 am 
Newbie

Joined: Wed Oct 05, 2005 1:20 pm
Posts: 15
Location: Russia Izhevsk
Hello

I have faced with the following problem. I use Hibernate-3.1.3 with ClassicQueryTranslatorFactory under MySQL 4.0.20d.

I need the SQL function "day". MySQL 4.0 does not have day function, but it has equal "dayofmonth". MySQLDialect.java has the following definition:

Code:
        registerFunction("day", new StandardSQLFunction("day", Hibernate.INTEGER) );


In order to have compatibility both with MySQL 4.0 and above I have written my own Dialect which override day function in the following way:

Code:
        registerFunction("day", new StandardSQLFunction("dayofmonth", Hibernate.INTEGER) );


With ASTQueryTranslator this dialect works corrrectly, but with Classic one it does not work!!!

I have examined Hibernate SRC and have found out that we have follwing code in the org.hibernate.hql.classic.SelectParser: 126

Code:
        else if ( getFunction( lctoken, q ) != null && token.equals( q.unalias( token ) ) ) {
            // the name of an SQL function
            if ( !ready ) throw new QueryException( ", expected before aggregate function in SELECT: " + token );
            aggregate = true;
            aggregateAddSelectScalar = true;
            aggregateFuncTokenList.add( lctoken );
            ready = false;
            q.appendScalarSelectToken( token );
            if ( !aggregateHasArgs( lctoken, q ) ) {
                q.addSelectScalar( aggregateType( aggregateFuncTokenList, null, q ) );
                if ( !aggregateFuncNoArgsHasParenthesis( lctoken, q ) ) {
                    aggregateFuncTokenList.removeLast();
                    if ( aggregateFuncTokenList.size() < 1 ) {
                        aggregate = false;
                        ready = false;
                    }
                    else {
                        ready = true;
                    }
                }
            }
        }


we can see that we call
Code:
q.appendScalarSelectToken( token );

function with original token, we do not use "render" method of org.hibernate.dialect.function.StandardSQLFunction.

Is this a bug of classic translator?

I am obliged to use Classic translator because Weblogic's problems with AST. Please give me an advice.

Thanks beforehand.

_________________
--
Andrey Grebnev
http://www.jroller.com/page/agrebnev


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.