[jira] [Updated] (OPENJPA-2729) problem with ToUpperCase and ToLowerCase

2020-10-18 Thread Patrice DUROUX (Jira)


 [ 
https://issues.apache.org/jira/browse/OPENJPA-2729?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Patrice DUROUX updated OPENJPA-2729:

Attachment: openjpa-test.zip

> problem with ToUpperCase and ToLowerCase
> 
>
> Key: OPENJPA-2729
> URL: https://issues.apache.org/jira/browse/OPENJPA-2729
> Project: OpenJPA
>  Issue Type: Bug
>  Components: query
>Affects Versions: 2.4.2
> Environment: MySQL
>Reporter: Patrice DUROUX
>Priority: Major
> Attachments: openjpa-test.zip
>
>
> Hi,
> An exception is thrown in the following method (here the one of ToLowerCase):
> when the getValue() is a PCPath and ((PCPath) 
> getValue()).getFieldMapping(state).getColumns()[0])
> throws:
> {{java.lang.ArrayIndexOutOfBoundsException: 0}}{{ 
> org.apache.openjpa.jdbc.kernel.exps.ToLowerCase.appendTo(ToLowerCase.java:47) 
> org.apache.openjpa.jdbc.kernel.exps.MatchesExpression.appendTo(MatchesExpression.java:97)
>  
> org.apache.openjpa.jdbc.kernel.exps.AndExpression.appendTo(AndExpression.java:59)}}
>  
>  
> {{    public void appendTo(Select sel, ExpContext ctx, ExpState state, }}
> {{    SQLBuffer buf, int index) {}}
> {{    DBDictionary dict = ctx.store.getDBDictionary();}}
> {{    String func = dict.toLowerCaseFunction;}}
> {{    dict.assertSupport(func != null, "ToLowerCaseFunction");}}
> {{    if (getValue() instanceof PCPath) {}}
> {{    func = dict.getCastFunction(getValue(), func, ((PCPath) 
> getValue()).getFieldMapping(state).getColumns()[0]);}}
> {{    } else {}}
> {{    func = dict.getCastFunction(getValue(), func);}}
> {{    }}}
> {{    int idx = func.indexOf("\{0}");}}
> {{    buf.append(func.substring(0, idx));}}
> {{    getValue().appendTo(sel, ctx, state, buf, index);}}
> {{    buf.append(func.substring(idx + 3));}}
> {{    }}}
> The part of code that generate the exception is:
>     Path authorPath = from.join("references").join("authors");
>         predicateList.add(cb.like(cb.lower(authorPath), cb.literal('%' + 
> value + '%')));
> If I change this code to use another string function like trim(), it works 
> (ie. the SQL query is correctly generated).
>  
> Regards,
> Patrice
> ps: remark that the only uses of DBDictionary.getCastFunction(Val val, String 
> func, Column col) are for those classes.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (OPENJPA-2729) problem with ToUpperCase and ToLowerCase

2018-03-06 Thread Patrice DUROUX (JIRA)

 [ 
https://issues.apache.org/jira/browse/OPENJPA-2729?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Patrice DUROUX updated OPENJPA-2729:

Summary: problem with ToUpperCase and ToLowerCase  (was: problem with 
ToUperCase and ToLowerCase)

> problem with ToUpperCase and ToLowerCase
> 
>
> Key: OPENJPA-2729
> URL: https://issues.apache.org/jira/browse/OPENJPA-2729
> Project: OpenJPA
>  Issue Type: Bug
>  Components: query
>Affects Versions: 2.4.2
> Environment: MySQL
>Reporter: Patrice DUROUX
>Priority: Major
>
> Hi,
> An exception is thrown in the following method (here the one of ToLowerCase):
> when the getValue() is a PCPath and ((PCPath) 
> getValue()).getFieldMapping(state).getColumns()[0])
> throws:
> {{java.lang.ArrayIndexOutOfBoundsException: 0}}{{ 
> org.apache.openjpa.jdbc.kernel.exps.ToLowerCase.appendTo(ToLowerCase.java:47) 
> org.apache.openjpa.jdbc.kernel.exps.MatchesExpression.appendTo(MatchesExpression.java:97)
>  
> org.apache.openjpa.jdbc.kernel.exps.AndExpression.appendTo(AndExpression.java:59)}}
>  
>  
> {{    public void appendTo(Select sel, ExpContext ctx, ExpState state, }}
> {{    SQLBuffer buf, int index) {}}
> {{    DBDictionary dict = ctx.store.getDBDictionary();}}
> {{    String func = dict.toLowerCaseFunction;}}
> {{    dict.assertSupport(func != null, "ToLowerCaseFunction");}}
> {{    if (getValue() instanceof PCPath) {}}
> {{    func = dict.getCastFunction(getValue(), func, ((PCPath) 
> getValue()).getFieldMapping(state).getColumns()[0]);}}
> {{    } else {}}
> {{    func = dict.getCastFunction(getValue(), func);}}
> {{    }}}
> {{    int idx = func.indexOf("\{0}");}}
> {{    buf.append(func.substring(0, idx));}}
> {{    getValue().appendTo(sel, ctx, state, buf, index);}}
> {{    buf.append(func.substring(idx + 3));}}
> {{    }}}
> The part of code that generate the exception is:
>     Path authorPath = from.join("references").join("authors");
>         predicateList.add(cb.like(cb.lower(authorPath), cb.literal('%' + 
> value + '%')));
> If I change this code to use another string function like trim(), it works 
> (ie. the SQL query is correctly generated).
>  
> Regards,
> Patrice
> ps: remark that the only uses of DBDictionary.getCastFunction(Val val, String 
> func, Column col) are for those classes.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)