derby + cayenne (ignoreCase)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

derby + cayenne (ignoreCase)

Valentin Bosilkov
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: derby + cayenne (ignoreCase)

Mike Kienenberger-2
Can you open a JIRA issue and provide a patch?

It would be better to provide the patch by creating translators specific for
the Derby DBAdaptor rather than applying it against the file shared by all
DBAdaptors.  You can reference the OpenBase adaptor as an example of how to
provide custom SQL for performing LIKE operations, as it also has custom
LIKE sql.

-Mike



Valentin Bosilkov <[hidden email]> wrote:

> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: derby + cayenne (ignoreCase)

Valentin Bosilkov
I have doubts I can make GOOD patch ... it'll be better someone else to do
it :PPP
or I can try  to fix it my own


From: "Mike Kienenberger" <[hidden email]>
To: <[hidden email]>
Cc: <[hidden email]>
Sent: Wednesday, August 10, 2005 12:53 AM
Subject: Re: derby + cayenne (ignoreCase)


> Can you open a JIRA issue and provide a patch?
>
> It would be better to provide the patch by creating translators specific
> for
> the Derby DBAdaptor rather than applying it against the file shared by all
> DBAdaptors.  You can reference the OpenBase adaptor as an example of how
> to
> provide custom SQL for performing LIKE operations, as it also has custom
> LIKE sql.
>
> -Mike
>
>
>
> Valentin Bosilkov <[hidden email]> wrote:
>> 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
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: derby + cayenne (ignoreCase)

Mike Kienenberger-2
Valentin Bosilkov <[hidden email]> wrote:
> I have doubts I can make GOOD patch ... it'll be better someone else to do

> it :PPP
> or I can try  to fix it my own

I said the same thing when I created the OpenBase adaptor patch :)
We all had to start somewhere :)

You're the most familiar with the problem, and have the most to gain by
writing the patch.

Whichever committer commits it (probably not me as I've never used Derby)
will look it over and make changes if necessary.

-Mike
Loading...