rzo1 opened a new pull request, #331: URL: https://github.com/apache/openjpa/pull/331
https://issues.apache.org/jira/browse/OPENJPA-2729 `LOWER()` and `UPPER()` failed with `ArrayIndexOutOfBoundsException: 0` in `ToLowerCase.appendTo` / `ToUpperCase.appendTo` when used on an element of an element collection of strings (e.g. `cb.lower(root.join("references").join("authors"))` or JPQL `lower(n)` with `join p.nickNames n`) or on the key or value of an element collection map. `TRIM()` and the other string functions on the same path worked. Cause: to pick the cast function, both classes passed `((PCPath) getValue()).getFieldMapping(state).getColumns()[0]` to `DBDictionary.getCastFunction(Val, String, Column)`. For an element collection the field mapping has no columns of its own; the element, key or value column lives in the collection table. Fix: new helper `StringFunction.getColumn(ExpState, int)` that takes the column from `PCPath.getColumns(state)`, the same columns `PCPath.appendTo` writes into the SQL. `ToLowerCase` and `ToUpperCase` pass it to `getCastFunction` when there is one, otherwise they call `getCastFunction(val, func)` without a column. No other class in `kernel.exps` uses the old pattern. `DB2Dictionary` is the only dictionary that looks at the column. Tests (Derby): new `TestCaseFunctionOnElementCollection`, criteria and JPQL `LOWER`/`UPPER` on a joined element of a `Set<String>` element collection (including `LIKE` as in the report), on the collection path itself, and on the key and value of a `Map<String,String>` element collection, in the select and the where clause. All fail with the `ArrayIndexOutOfBoundsException` without the fix. The openjpa-kernel and openjpa-jdbc suites and the query, criteria, jpql, embed and map packages of openjpa-persistence-jdbc pass. TCK: https://github.com/apache/openjpa/actions/runs/46485252911, Databases: https://github.com/apache/openjpa/actions/runs/46485260097 (running) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
