derby + cayenne (ignoreCase)

From: Valentin Bosilkov (vbosilko..cygen.com)
Date: Mon Aug 08 2005 - 07:04:32 EDT

  • Next message: Mike Kienenberger: "Re: derby + cayenne (ignoreCase)"

    Hi ,

    I'm using Cayenne1.2M5 + DERBY , but it's seems there is A PROBLEM:
    when I want to execute

    dataContext.executeQuery(new SelectQuery(Company.class,ExpressionFactory.likeIgnoreCaseExp(Company.NAME_PROPERTY,"icygen")));

    it throws same Exception if I make

    c.createStatement().executeQuery("select id_company ,name from company where upper(name) like upper(\'icygen\')");

    ---------------------------------------------------------------------------------------------------------------------------------------------------

    162409 [AWT-EventQueue-0] INFO org.objectstyle.cayenne.access.QueryLogger - SELECT t0.NAME, t0.ID_COMPANY FROM COMPANY t0 WHERE UPPER(t0.NAME) LIKE UPPER(?) [bind: 'asdasdf']

    162440 [AWT-EventQueue-0] INFO org.objectstyle.cayenne.access.QueryLogger - *** error.

    ERROR 42884: No authorized routine named 'LIKE' of type 'FUNCTION' having compatible arguments was found.

     at org.apache.derby.iapi.error.StandardException.newException(StandardException.java)

     at org.apache.derby.impl.sql.compile.LikeEscapeOperatorNode.bindExpression(LikeEscapeOperatorNode.java)

     at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(SelectNode.java)

     at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(DMLStatementNode.java)

     at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java)

     at org.apache.derby.impl.sql.compile.ReadCursorNode.bind(ReadCursorNode.java)

     at org.apache.derby.impl.sql.compile.CursorNode.bind(CursorNode.java)

     at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java)

     at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java)

     at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java)

     at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java)

     at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(EmbedPreparedStatement20.java)

     at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(EmbedPreparedStatement30.java)

     at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Driver30.java)

     at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java)

     at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java)

     at org.objectstyle.cayenne.access.trans.QueryAssembler.createStatement(QueryAssembler.java:137)

     at org.objectstyle.cayenne.access.jdbc.SelectAction.performAction(SelectAction.java:104)

     at org.objectstyle.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:95)

     at org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:303)

     at org.objectstyle.cayenne.access.DataDomain.performQuery(DataDomain.java:695)

     at org.objectstyle.cayenne.access.DataDomain.performQueries(DataDomain.java:531)

     at org.objectstyle.cayenne.access.DataContext.performQueries(DataContext.java:1120)

     at org.objectstyle.cayenne.access.Transaction.performQueries(Transaction.java:180)

     at org.objectstyle.cayenne.access.DataContext.performQueries(DataContext.java:1078)

     at org.objectstyle.cayenne.access.DataContextSelectAction.performQuery(DataContextSelectAction.java:149)

     at org.objectstyle.cayenne.access.DataContextSelectAction.performQuery(DataContextSelectAction.java:83)

     at org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.java:1187)

    --------------------------------------------------------------------------------------------------------------------

    but derby works with .... <<<select id_company ,name from company where upper(name) like (\'ICYGEN\')>>>

    so ... I find this solution ....

    ASTLikeIgnoreCase.java

        public ASTLikeIgnoreCase(ASTPath path, Object pattern) {
            super(ExpressionParserTreeConstants.JJTLIKEIGNORECASE, false);
            jjtAddChild(path, 0);
            jjtAddChild(wrapChild(((String)pattern).toUpperCase()), 1);
        }

    QualifierTranslator

        public void finishedChild(Expression node, int childIndex, boolean hasMoreChildren) {

    line : 271 :

                case Expression.LIKE_IGNORE_CASE :
                    buf.append(") LIKE UPPER(");
                    break;
     
    becomes :
                case Expression.LIKE_IGNORE_CASE :
                    buf.append(") LIKE (");
                    break;

    is it correct OR you can give me other "smarter" solution?

    P.S.
    probably there is same mistake with notLikeIgnoreCase

    Best Regards,
    badValue



    This archive was generated by hypermail 2.0.0 : Mon Aug 08 2005 - 07:04:39 EDT