Community
Participate
Working Groups
In java toUpperCase("ß") results in "SS", e.g. oracle UPPER('ß') results in 'ß'. The best way to get it working use lower instead of upper. No Entities with a name containing an ß can be found. current: /** * PUBLIC: * Return an expression that compares if the receivers value is like the other value, ignoring case. * This is a case in-sensitive like. * <p>Example: * <pre><blockquote> * EclipseLink: employee.get("firstName").likeIgnoreCase("%Bob%") * Java: none * SQL: UPPER(F_NAME) LIKE '%BOB%' * </blockquote></pre> */ public Expression likeIgnoreCase(String theValue) { return toUpperCase().like(theValue.toUpperCase()); } new: /** * PUBLIC: * Return an expression that compares if the receivers value is like the other value, ignoring case. * This is a case in-sensitive like. * <p>Example: * <pre><blockquote> * EclipseLink: employee.get("firstName").likeIgnoreCase("%Bob%") * Java: none * SQL: LOWER(F_NAME) LIKE '%bob%' * </blockquote></pre> */ public Expression likeIgnoreCase(String theValue) { return toLowerCase().like(theValue.toLowerCase()); }
oracle stands for "Oracle RDBMS 11g"
the class Expression is located in org.eclipse.persistence.expressions
the version 2.5.0 shows the same behavior
Created attachment 219348 [details] Patch-File for 2.2.0 replaced all toUpperCase by toLowerCase in methods with ignoreCase
Created attachment 219349 [details] Patch-File for 2.5.0-M1
Comment on attachment 219349 [details] Patch-File for 2.5.0-M1 Index: foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/expressions/Expression.java =================================================================== --- foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/expressions/Expression.java (revision 11856) +++ foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/expressions/Expression.java (working copy) @@ -1519,7 +1519,7 @@ * </blockquote></pre> */ public Expression equalsIgnoreCase(String theValue) { - return toUpperCase().equal(theValue.toUpperCase()); + return toLowerCase().equal(theValue.toLowerCase()); } /** @@ -1534,7 +1534,7 @@ * </blockquote></pre> */ public Expression equalsIgnoreCase(Expression theValue) { - return toUpperCase().equal(theValue.toUpperCase()); + return toLowerCase().equal(theValue.toLowerCase()); } /** @@ -3009,7 +3009,7 @@ * </blockquote></pre> */ public Expression likeIgnoreCase(String theValue) { - return toUpperCase().like(theValue.toUpperCase()); + return toLowerCase().like(theValue.toLowerCase()); } /** @@ -3018,7 +3018,7 @@ * This is a case in-sensitive like. */ public Expression likeIgnoreCase(Expression theValue) { - return toUpperCase().like(theValue.toUpperCase()); + return toLowerCase().like(theValue.toLowerCase()); } /**
Created attachment 219350 [details] Patch for 2.5.0-M1 based on root folder
(In reply to comment #6) > Comment on attachment 219349 [details] > Patch-File for 2.5.0-M1 > > Index: > foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/ > expressions/Expression.java > =================================================================== > --- > foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/ > expressions/Expression.java (revision 11856) > +++ > foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/ > expressions/Expression.java (working copy) > @@ -1519,7 +1519,7 @@ > * </blockquote></pre> > */ > public Expression equalsIgnoreCase(String theValue) { > - return toUpperCase().equal(theValue.toUpperCase()); > + return toLowerCase().equal(theValue.toLowerCase()); > } > > /** > @@ -1534,7 +1534,7 @@ > * </blockquote></pre> > */ > public Expression equalsIgnoreCase(Expression theValue) { > - return toUpperCase().equal(theValue.toUpperCase()); > + return toLowerCase().equal(theValue.toLowerCase()); > } > > /** > @@ -3009,7 +3009,7 @@ > * </blockquote></pre> > */ > public Expression likeIgnoreCase(String theValue) { > - return toUpperCase().like(theValue.toUpperCase()); > + return toLowerCase().like(theValue.toLowerCase()); > } > > /** > @@ -3018,7 +3018,7 @@ > * This is a case in-sensitive like. > */ > public Expression likeIgnoreCase(Expression theValue) { > - return toUpperCase().like(theValue.toUpperCase()); > + return toLowerCase().like(theValue.toLowerCase()); > } > > /** oops, can be ignored
We have discussed the option above. The concern we have is that in other languages, toLowerCase will have the same issue as toUpperCase has for german.
Can you please give an example of a language in which there is a problem with toLowerCase. Just out of curiosity.
I cannot give an example, I am simply pointing that possibility out as a risk and a reason we need to consider other possibilities for fixing this issue.
Your message sounded so definite that I assumed you already had an example.
Created attachment 219389 [details] Test Case for Java String.toUpperCase() a small Java test case to check which characters are converted to multi character strings
Created attachment 219394 [details] Java Test Case with all available locales test each locale
Hi Tom, I've created two test cases in order to compare the shortcomings between toLowerCase and toUpperCase. The test case "with all available locales" print out a statistic sorted by the total number of mismatches (lowerCase + upperCase). Most of the mismatches are observed in LT and TR. Only these two locales have problems with toLowerCase, however, the UTF-8 byte sequence in LT is equal, strange ;-) The toUpperCase method has a minimum of 75 problems. Kind regards, Jörg
(In reply to comment #15) > Hi Tom, > > I've created two test cases in order to compare the shortcomings between > toLowerCase and toUpperCase. > > The test case "with all available locales" print out a statistic sorted by > the total number of mismatches (lowerCase + upperCase). > Most of the mismatches are observed in LT and TR. > Only these two locales have problems with toLowerCase, however, the UTF-8 > byte sequence in LT is equal, strange ;-) > > The toUpperCase method has a minimum of 75 problems. > > Kind regards, > Jörg I made a mistake at the output, because I did not take into account the locale. The utf-8 byte sequence differ in LT.
Created attachment 219632 [details] Java Test Case with all available locales takes into account the locale
Created attachment 219834 [details] Proposed / Potential fix Fix uses a constant expression for String parameters in case-insensitive Expression methods. Constant expression is then passed to the corresponding method that takes an expression as a parameter. The database is left to perform case insensitive comparisons using UPPER().
Created attachment 220024 [details] Proposed / Potential fix & testcase The attached patch provides a way for the Expression methods to use the lower() SQL function instead of the upper() function, which is currently used. The current default case insensitive behavior remains unchanged, as the upper() function is still the default. equalsIgnoreCase likeIgnoreCase containsSubstringIgnoringCase The following static methods were added to Expression to control this setting: void setUpperCaseForIgnoreCase(boolean) boolean isUpperCaseForIgnoreCase() Programmatically invoking org.eclipse.persistence.expressions.Expression.setUpperCaseForIgnoreCase(false) once will set this parameter globally for all expressions
Created attachment 220077 [details] Proposed fix & regression testcase Updated patch & testcase, taking into account some feedback. Programmatically configure the use of lower() for Expression case insensitive operations on Expression using the following public static flag: org.eclipse.persistence.expressions.Expression.shouldUseUpperCaseForIgnoreCase = false; The default value is true (use upper() for case insensitive expression operations).
Checked into trunk (2.5) SHA-1: e3433691240a250fdffbfbf3d6ca81f2d3da6872
Checked into 2.4 with hash: 2ccc0b110a142164ee221e1511f89b6d619477bd http://git.eclipse.org/c/eclipselink/eclipselink.runtime.git/commit/?h=2.4&id=2ccc0b110a142164ee221e1511f89b6d619477bd
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink