diff --git a/hibernate-core/src/main/java/org/hibernate/CacheMode.java b/hibernate-core/src/main/java/org/hibernate/CacheMode.java index 54ebf079a9..4c2247e0b9 100755 --- a/hibernate-core/src/main/java/org/hibernate/CacheMode.java +++ b/hibernate-core/src/main/java/org/hibernate/CacheMode.java @@ -23,6 +23,8 @@ */ package org.hibernate; +import java.util.Locale; + /** * Controls how the session interacts with the second-level cache and query cache. * @@ -100,7 +102,7 @@ public enum CacheMode { } try { - return CacheMode.valueOf( setting.toUpperCase() ); + return CacheMode.valueOf( setting.toUpperCase(Locale.ROOT) ); } catch ( IllegalArgumentException e ) { throw new MappingException( "Unknown Cache Mode: " + setting ); diff --git a/hibernate-core/src/main/java/org/hibernate/ConnectionReleaseMode.java b/hibernate-core/src/main/java/org/hibernate/ConnectionReleaseMode.java index 25309ca10e..189b52c984 100644 --- a/hibernate-core/src/main/java/org/hibernate/ConnectionReleaseMode.java +++ b/hibernate-core/src/main/java/org/hibernate/ConnectionReleaseMode.java @@ -23,6 +23,8 @@ */ package org.hibernate; +import java.util.Locale; + /** * Defines the various policies by which Hibernate might release its underlying * JDBC connection. @@ -61,6 +63,6 @@ public enum ConnectionReleaseMode{ * @return The matched enum value. */ public static ConnectionReleaseMode parse(final String name) { - return ConnectionReleaseMode.valueOf( name.toUpperCase() ); + return ConnectionReleaseMode.valueOf( name.toUpperCase(Locale.ROOT) ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/FlushMode.java b/hibernate-core/src/main/java/org/hibernate/FlushMode.java index 8a0dbacb93..8af4adb00f 100644 --- a/hibernate-core/src/main/java/org/hibernate/FlushMode.java +++ b/hibernate-core/src/main/java/org/hibernate/FlushMode.java @@ -23,6 +23,8 @@ */ package org.hibernate; +import java.util.Locale; + /** * Represents a flushing strategy. The flush process synchronizes * database state with session state by detecting state changes @@ -119,7 +121,7 @@ public enum FlushMode { } try { - return FlushMode.valueOf( externalName.toUpperCase() ); + return FlushMode.valueOf( externalName.toUpperCase(Locale.ROOT) ); } catch ( IllegalArgumentException e ) { throw new MappingException( "unknown FlushMode : " + externalName ); diff --git a/hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java b/hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java index 5f0f74f6cf..1c212c64c0 100644 --- a/hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/MultiTenancyStrategy.java @@ -23,6 +23,7 @@ */ package org.hibernate; +import java.util.Locale; import java.util.Map; import org.hibernate.cfg.Environment; @@ -88,7 +89,7 @@ public enum MultiTenancyStrategy { final String strategyName = strategy.toString(); try { - return MultiTenancyStrategy.valueOf( strategyName.toUpperCase() ); + return MultiTenancyStrategy.valueOf( strategyName.toUpperCase(Locale.ROOT) ); } catch ( RuntimeException e ) { LOG.warn( "Unknown multi tenancy strategy [ " +strategyName +" ], using MultiTenancyStrategy.NONE." ); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java b/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java index 14faf3aada..adc6592c19 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java @@ -25,6 +25,7 @@ package org.hibernate.cfg; import java.util.HashMap; import java.util.Iterator; +import java.util.Locale; import java.util.Map; import org.hibernate.AnnotationException; @@ -87,7 +88,7 @@ public class CopyIdentifierComponentSecondPass implements SecondPass { break; } //JPA 2 requires referencedColumnNames to be case insensitive - columnByReferencedName.put( referencedColumnName.toLowerCase(), joinColumn ); + columnByReferencedName.put( referencedColumnName.toLowerCase(Locale.ROOT), joinColumn ); } //try default column orientation int index = 0; @@ -142,7 +143,7 @@ public class CopyIdentifierComponentSecondPass implements SecondPass { final String columnName = column.getName(); logicalColumnName = mappings.getLogicalColumnName( columnName, referencedPersistentClass.getTable() ); //JPA 2 requires referencedColumnNames to be case insensitive - joinColumn = columnByReferencedName.get( logicalColumnName.toLowerCase() ); + joinColumn = columnByReferencedName.get( logicalColumnName.toLowerCase(Locale.ROOT ) ); } else { joinColumn = columnByReferencedName.get( "" + index ); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java b/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java index 805d7cd02f..c6c69da015 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java @@ -22,6 +22,7 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.cfg; +import java.util.Locale; import org.hibernate.AssertionFailure; import org.hibernate.internal.util.StringHelper; @@ -32,7 +33,7 @@ public class DefaultComponentSafeNamingStrategy extends EJB3NamingStrategy { public static final NamingStrategy INSTANCE = new DefaultComponentSafeNamingStrategy(); protected static String addUnderscores(String name) { - return name.replace( '.', '_' ).toLowerCase(); + return name.replace( '.', '_' ).toLowerCase(Locale.ROOT); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java b/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java index b9be3483c7..42ee43d672 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java @@ -24,6 +24,7 @@ package org.hibernate.cfg; import java.io.Serializable; +import java.util.Locale; import org.hibernate.AssertionFailure; import org.hibernate.internal.util.StringHelper; @@ -79,7 +80,7 @@ public class ImprovedNamingStrategy implements NamingStrategy, Serializable { buf.insert(i++, '_'); } } - return buf.toString().toLowerCase(); + return buf.toString().toLowerCase(Locale.ROOT); } public String collectionTableName( diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/JPAIndexHolder.java b/hibernate-core/src/main/java/org/hibernate/cfg/JPAIndexHolder.java index bd5f379e88..a95b3d4cf9 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/JPAIndexHolder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/JPAIndexHolder.java @@ -25,6 +25,7 @@ package org.hibernate.cfg; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.StringTokenizer; import javax.persistence.Index; @@ -70,7 +71,7 @@ public class JPAIndexHolder { private void initializeColumns(String[] columns, String[] ordering, List list) { for ( int i = 0, size = list.size(); i < size; i++ ) { final String description = list.get( i ); - final String tmp = description.toLowerCase(); + final String tmp = description.toLowerCase(Locale.ROOT); if ( tmp.endsWith( " desc" ) ) { columns[i] = description.substring( 0, description.length() - 5 ); ordering[i] = "desc"; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/VerifyFetchProfileReferenceSecondPass.java b/hibernate-core/src/main/java/org/hibernate/cfg/VerifyFetchProfileReferenceSecondPass.java index 72b6c2472e..6bd57ed658 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/VerifyFetchProfileReferenceSecondPass.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/VerifyFetchProfileReferenceSecondPass.java @@ -22,6 +22,7 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.cfg; +import java.util.Locale; import java.util.Map; import org.hibernate.MappingException; @@ -60,7 +61,7 @@ public class VerifyFetchProfileReferenceSecondPass implements SecondPass { clazz.getProperty( fetch.association() ); profile.addFetch( - fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase() + fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase(Locale.ROOT) ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java index acf8cbe99a..4466957854 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java @@ -26,6 +26,7 @@ package org.hibernate.cfg.annotations; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; +import java.util.Locale; import java.util.Map; import java.util.Properties; import javax.persistence.AttributeOverride; @@ -461,23 +462,23 @@ public abstract class CollectionBinder { Loader loader = property.getAnnotation( Loader.class ); if ( sqlInsert != null ) { collection.setCustomSQLInsert( sqlInsert.sql().trim(), sqlInsert.callable(), - ExecuteUpdateResultCheckStyle.fromExternalName( sqlInsert.check().toString().toLowerCase() ) + ExecuteUpdateResultCheckStyle.fromExternalName( sqlInsert.check().toString().toLowerCase(Locale.ROOT) ) ); } if ( sqlUpdate != null ) { collection.setCustomSQLUpdate( sqlUpdate.sql(), sqlUpdate.callable(), - ExecuteUpdateResultCheckStyle.fromExternalName( sqlUpdate.check().toString().toLowerCase() ) + ExecuteUpdateResultCheckStyle.fromExternalName( sqlUpdate.check().toString().toLowerCase(Locale.ROOT) ) ); } if ( sqlDelete != null ) { collection.setCustomSQLDelete( sqlDelete.sql(), sqlDelete.callable(), - ExecuteUpdateResultCheckStyle.fromExternalName( sqlDelete.check().toString().toLowerCase() ) + ExecuteUpdateResultCheckStyle.fromExternalName( sqlDelete.check().toString().toLowerCase(Locale.ROOT) ) ); } if ( sqlDeleteAll != null ) { collection.setCustomSQLDeleteAll( sqlDeleteAll.sql(), sqlDeleteAll.callable(), - ExecuteUpdateResultCheckStyle.fromExternalName( sqlDeleteAll.check().toString().toLowerCase() ) + ExecuteUpdateResultCheckStyle.fromExternalName( sqlDeleteAll.check().toString().toLowerCase(Locale.ROOT) ) ); } if ( loader != null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java index 0090734084..5d206d981a 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import javax.persistence.Access; import javax.persistence.Entity; import javax.persistence.JoinColumn; @@ -329,23 +330,23 @@ public class EntityBinder { if ( sqlInsert != null ) { persistentClass.setCustomSQLInsert( sqlInsert.sql().trim(), sqlInsert.callable(), - ExecuteUpdateResultCheckStyle.fromExternalName( sqlInsert.check().toString().toLowerCase() ) + ExecuteUpdateResultCheckStyle.fromExternalName( sqlInsert.check().toString().toLowerCase(Locale.ROOT) ) ); } if ( sqlUpdate != null ) { persistentClass.setCustomSQLUpdate( sqlUpdate.sql(), sqlUpdate.callable(), - ExecuteUpdateResultCheckStyle.fromExternalName( sqlUpdate.check().toString().toLowerCase() ) - ); + ExecuteUpdateResultCheckStyle.fromExternalName( sqlUpdate.check().toString().toLowerCase(Locale.ROOT) ) + );Locale.ROOT } if ( sqlDelete != null ) { persistentClass.setCustomSQLDelete( sqlDelete.sql(), sqlDelete.callable(), - ExecuteUpdateResultCheckStyle.fromExternalName( sqlDelete.check().toString().toLowerCase() ) + ExecuteUpdateResultCheckStyle.fromExternalName( sqlDelete.check().toString().toLowerCase(Locale.ROOT) ) ); } if ( sqlDeleteAll != null ) { persistentClass.setCustomSQLDelete( sqlDeleteAll.sql(), sqlDeleteAll.callable(), - ExecuteUpdateResultCheckStyle.fromExternalName( sqlDeleteAll.check().toString().toLowerCase() ) + ExecuteUpdateResultCheckStyle.fromExternalName( sqlDeleteAll.check().toString().toLowerCase(Locale.ROOT) ) ); } if ( loader != null ) { @@ -864,7 +865,7 @@ public class EntityBinder { join.setCustomSQLInsert( matchingTable.sqlInsert().sql().trim(), matchingTable.sqlInsert().callable(), ExecuteUpdateResultCheckStyle.fromExternalName( - matchingTable.sqlInsert().check().toString().toLowerCase() + matchingTable.sqlInsert().check().toString().toLowerCase(Locale.ROOT) ) ); } @@ -872,7 +873,7 @@ public class EntityBinder { join.setCustomSQLUpdate( matchingTable.sqlUpdate().sql().trim(), matchingTable.sqlUpdate().callable(), ExecuteUpdateResultCheckStyle.fromExternalName( - matchingTable.sqlUpdate().check().toString().toLowerCase() + matchingTable.sqlUpdate().check().toString().toLowerCase(Locale.ROOT) ) ); } @@ -880,7 +881,7 @@ public class EntityBinder { join.setCustomSQLDelete( matchingTable.sqlDelete().sql().trim(), matchingTable.sqlDelete().callable(), ExecuteUpdateResultCheckStyle.fromExternalName( - matchingTable.sqlDelete().check().toString().toLowerCase() + matchingTable.sqlDelete().check().toString().toLowerCase(Locale.ROOT) ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverriddenAnnotationReader.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverriddenAnnotationReader.java index b9c1d123af..6d16dffd64 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverriddenAnnotationReader.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/JPAOverriddenAnnotationReader.java @@ -34,6 +34,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import javax.persistence.Access; @@ -1980,7 +1981,7 @@ public class JPAOverriddenAnnotationReader implements AnnotationReader { parameterDescriptor.setValue( "mode", ParameterMode.IN ); } else { - parameterDescriptor.setValue( "mode", ParameterMode.valueOf( modeValue.toUpperCase() ) ); + parameterDescriptor.setValue( "mode", ParameterMode.valueOf( modeValue.toUpperCase(Locale.ROOT) ) ); } String clazzName = parameterElement.attributeValue( "class" ); Class clazz; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/ValidationMode.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/ValidationMode.java index 29bbda0413..2e5be99edd 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/ValidationMode.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/ValidationMode.java @@ -24,6 +24,7 @@ package org.hibernate.cfg.beanvalidation; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import org.hibernate.HibernateException; @@ -68,7 +69,7 @@ public enum ValidationMode { } else { try { - return valueOf( modeProperty.trim().toUpperCase() ); + return valueOf( modeProperty.trim().toUpperCase(Locale.ROOT) ); } catch ( IllegalArgumentException e ) { throw new HibernateException( "Unknown validation mode in " + BeanValidationIntegrator.MODE_PROPERTY + ": " + modeProperty ); diff --git a/hibernate-core/src/main/java/org/hibernate/criterion/Example.java b/hibernate-core/src/main/java/org/hibernate/criterion/Example.java index 44a9abc6fe..2ba7beee50 100644 --- a/hibernate-core/src/main/java/org/hibernate/criterion/Example.java +++ b/hibernate-core/src/main/java/org/hibernate/criterion/Example.java @@ -27,6 +27,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import org.hibernate.Criteria; @@ -289,7 +290,7 @@ public class Example implements Criterion { if ( value instanceof String ) { String string = (String) value; if ( isIgnoreCaseEnabled ) { - string = string.toLowerCase(); + string = string.toLowerCase(Locale.ROOT); } if ( isLikeEnabled ) { string = matchMode.toMatchString( string ); diff --git a/hibernate-core/src/main/java/org/hibernate/criterion/IlikeExpression.java b/hibernate-core/src/main/java/org/hibernate/criterion/IlikeExpression.java index 923890bcaf..62a4f3d684 100644 --- a/hibernate-core/src/main/java/org/hibernate/criterion/IlikeExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/criterion/IlikeExpression.java @@ -24,6 +24,7 @@ */ package org.hibernate.criterion; +import java.util.Locale; import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.dialect.Dialect; @@ -74,7 +75,7 @@ public class IlikeExpression implements Criterion { criteriaQuery.getTypedValue( criteria, propertyName, - value.toString().toLowerCase() + value.toString().toLowerCase(Locale.ROOT) ) }; } diff --git a/hibernate-core/src/main/java/org/hibernate/criterion/Junction.java b/hibernate-core/src/main/java/org/hibernate/criterion/Junction.java index d9cde4b3b3..3f85e45531 100644 --- a/hibernate-core/src/main/java/org/hibernate/criterion/Junction.java +++ b/hibernate-core/src/main/java/org/hibernate/criterion/Junction.java @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Locale; import org.hibernate.Criteria; import org.hibernate.HibernateException; @@ -132,7 +133,7 @@ public class Junction implements Criterion { * @return SQL operator */ public String getOperator() { - return name().toLowerCase(); + return name().toLowerCase(Locale.ROOT); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/criterion/LikeExpression.java b/hibernate-core/src/main/java/org/hibernate/criterion/LikeExpression.java index eb71480ab2..1de76ad7c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/criterion/LikeExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/criterion/LikeExpression.java @@ -23,6 +23,7 @@ */ package org.hibernate.criterion; +import java.util.Locale; import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.dialect.Dialect; @@ -94,7 +95,7 @@ public class LikeExpression implements Criterion { @Override public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) { - final String matchValue = ignoreCase ? value.toString().toLowerCase() : value.toString(); + final String matchValue = ignoreCase ? value.toString().toLowerCase(Locale.ROOT) : value.toString(); return new TypedValue[] { criteriaQuery.getTypedValue( criteria, propertyName, matchValue ) }; } diff --git a/hibernate-core/src/main/java/org/hibernate/criterion/Order.java b/hibernate-core/src/main/java/org/hibernate/criterion/Order.java index dd3adccccb..979a10d296 100644 --- a/hibernate-core/src/main/java/org/hibernate/criterion/Order.java +++ b/hibernate-core/src/main/java/org/hibernate/criterion/Order.java @@ -25,6 +25,7 @@ package org.hibernate.criterion; import java.io.Serializable; import java.sql.Types; +import java.util.Locale; import org.hibernate.Criteria; import org.hibernate.NullPrecedence; @@ -167,6 +168,6 @@ public class Order implements Serializable { public String toString() { return propertyName + ' ' + ( ascending ? "asc" : "desc" ) - + ( nullPrecedence != null ? ' ' + nullPrecedence.name().toLowerCase() : "" ); + + ( nullPrecedence != null ? ' ' + nullPrecedence.name().toLowerCase(Locale.ROOT) : "" ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/criterion/SimpleExpression.java b/hibernate-core/src/main/java/org/hibernate/criterion/SimpleExpression.java index b8d80f0651..b1ef137a1e 100644 --- a/hibernate-core/src/main/java/org/hibernate/criterion/SimpleExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/criterion/SimpleExpression.java @@ -24,6 +24,7 @@ package org.hibernate.criterion; import java.sql.Types; +import java.util.Locale; import org.hibernate.Criteria; import org.hibernate.HibernateException; @@ -111,7 +112,7 @@ public class SimpleExpression implements Criterion { @Override public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { - final Object casedValue = ignoreCase ? value.toString().toLowerCase() : value; + final Object casedValue = ignoreCase ? value.toString().toLowerCase(Locale.ROOT) : value; return new TypedValue[] { criteriaQuery.getTypedValue( criteria, propertyName, casedValue ) }; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java index a79822b2e5..b5dfd0d4db 100755 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java @@ -25,6 +25,7 @@ package org.hibernate.dialect; import java.lang.reflect.Method; import java.sql.Types; +import java.util.Locale; import org.hibernate.MappingException; import org.hibernate.dialect.function.AnsiTrimFunction; @@ -186,7 +187,7 @@ public class DerbyDialect extends DB2Dialect { @Override public String getLimitString(String query, final int offset, final int limit) { final StringBuilder sb = new StringBuilder(query.length() + 50); - final String normalizedSelect = query.toLowerCase().trim(); + final String normalizedSelect = query.toLowerCase(Locale.ROOT).trim(); final int forUpdateIndex = normalizedSelect.lastIndexOf( "for update") ; if ( hasForUpdateClause( forUpdateIndex ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index 4a1787d150..77fced782b 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -23,23 +23,6 @@ */ package org.hibernate.dialect; -import java.io.InputStream; -import java.io.OutputStream; -import java.sql.Blob; -import java.sql.CallableStatement; -import java.sql.Clob; -import java.sql.NClob; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.LockOptions; @@ -92,9 +75,26 @@ import org.hibernate.sql.JoinFragment; import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.descriptor.sql.ClobTypeDescriptor; import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; - import org.jboss.logging.Logger; +import java.io.InputStream; +import java.io.OutputStream; +import java.sql.Blob; +import java.sql.CallableStatement; +import java.sql.Clob; +import java.sql.NClob; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + /** * Represents a dialect of SQL implemented by a particular RDBMS. Subclasses implement Hibernate compatibility * with different systems. Subclasses should provide a public default constructor that register a set of type @@ -692,7 +692,7 @@ public abstract class Dialect implements ConversionContext { protected void registerFunction(String name, SQLFunction function) { // HHH-7721: SQLFunctionRegistry expects all lowercase. Enforce, // just in case a user's customer dialect uses mixed cases. - sqlFunctions.put( name.toLowerCase(), function ); + sqlFunctions.put( name.toLowerCase(Locale.ROOT), function ); } /** @@ -2370,7 +2370,7 @@ public abstract class Dialect implements ConversionContext { orderByElement.append( " " ).append( order ); } if ( nulls != NullPrecedence.NONE ) { - orderByElement.append( " nulls " ).append( nulls.name().toLowerCase() ); + orderByElement.append( " nulls " ).append( nulls.name().toLowerCase(Locale.ROOT) ); } return orderByElement.toString(); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java index a6d8b5a50b..d8e5f293f1 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java @@ -23,10 +23,6 @@ */ package org.hibernate.dialect; -import java.io.Serializable; -import java.sql.SQLException; -import java.sql.Types; - import org.hibernate.JDBCException; import org.hibernate.LockMode; import org.hibernate.MappingException; @@ -52,9 +48,13 @@ import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.persister.entity.Lockable; import org.hibernate.type.StandardBasicTypes; - import org.jboss.logging.Logger; +import java.io.Serializable; +import java.sql.SQLException; +import java.sql.Types; +import java.util.Locale; + /** * An SQL dialect compatible with HSQLDB (HyperSQL). *

@@ -278,7 +278,7 @@ public class HSQLDialect extends Dialect { return new StringBuilder( sql.length() + 10 ) .append( sql ) .insert( - sql.toLowerCase().indexOf( "select" ) + 6, + sql.toLowerCase(Locale.ROOT).indexOf( "select" ) + 6, hasOffset ? " limit ? ?" : " top ?" ) .toString(); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java index 65d4b7287e..cb09ef8d6a 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java @@ -25,6 +25,7 @@ package org.hibernate.dialect; import java.sql.SQLException; import java.sql.Types; +import java.util.Locale; import org.hibernate.MappingException; import org.hibernate.dialect.function.VarArgsSQLFunction; @@ -212,7 +213,7 @@ public class InformixDialect extends Dialect { } return new StringBuilder( querySelect.length() + 8 ) .append( querySelect ) - .insert( querySelect.toLowerCase().indexOf( "select" ) + 6, " first " + limit ) + .insert( querySelect.toLowerCase(Locale.ROOT).indexOf( "select" ) + 6, " first " + limit ) .toString(); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/InterbaseDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/InterbaseDialect.java index 746f42c17b..8a3c73db13 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/InterbaseDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/InterbaseDialect.java @@ -23,6 +23,7 @@ */ package org.hibernate.dialect; import java.sql.Types; +import java.util.Locale; import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.NoArgSQLFunction; @@ -88,7 +89,7 @@ public class InterbaseDialect extends Dialect { @Override public String getDropSequenceString(String sequenceName) { - return "delete from RDB$GENERATORS where RDB$GENERATOR_NAME = '" + sequenceName.toUpperCase() + "'"; + return "delete from RDB$GENERATORS where RDB$GENERATOR_NAME = '" + sequenceName.toUpperCase(Locale.ROOT) + "'"; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java index a834d337d9..ee6f573193 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java @@ -28,6 +28,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import java.util.List; +import java.util.Locale; import org.hibernate.JDBCException; import org.hibernate.QueryTimeoutException; @@ -62,6 +63,7 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; */ @SuppressWarnings("deprecation") public class Oracle8iDialect extends Dialect { + private static final int PARAM_LIST_SIZE_LIMIT = 1000; /** @@ -247,7 +249,7 @@ public class Oracle8iDialect extends Dialect { public String getLimitString(String sql, boolean hasOffset) { sql = sql.trim(); boolean isForUpdate = false; - if ( sql.toLowerCase().endsWith( " for update" ) ) { + if ( sql.toLowerCase(Locale.ROOT).endsWith( " for update" ) ) { sql = sql.substring( 0, sql.length()-11 ); isForUpdate = true; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java index cf04dbadb2..fdc9f843a7 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java @@ -27,6 +27,7 @@ import java.sql.CallableStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; +import java.util.Locale; import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.NoArgSQLFunction; @@ -242,7 +243,7 @@ public class Oracle9Dialect extends Dialect { sql = sql.trim(); boolean isForUpdate = false; - if ( sql.toLowerCase().endsWith( " for update" ) ) { + if ( sql.toLowerCase(Locale.ROOT).endsWith( " for update" ) ) { sql = sql.substring( 0, sql.length() - 11 ); isForUpdate = true; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java index 687d23bdaa..23f908458d 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9iDialect.java @@ -24,6 +24,7 @@ package org.hibernate.dialect; import java.sql.Types; +import java.util.Locale; import org.hibernate.LockOptions; import org.hibernate.sql.ANSICaseFragment; @@ -37,6 +38,7 @@ import org.hibernate.sql.CaseFragment; * @author Steve Ebersole */ public class Oracle9iDialect extends Oracle8iDialect { + @Override protected void registerCharacterTypeMappings() { registerColumnType( Types.CHAR, "char(1 char)" ); @@ -62,7 +64,7 @@ public class Oracle9iDialect extends Oracle8iDialect { sql = sql.trim(); String forUpdateClause = null; boolean isForUpdate = false; - final int forUpdateIndex = sql.toLowerCase().lastIndexOf( "for update") ; + final int forUpdateIndex = sql.toLowerCase(Locale.ROOT).lastIndexOf( "for update") ; if ( forUpdateIndex > -1 ) { // save 'for update ...' and then remove it forUpdateClause = sql.substring( forUpdateIndex ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java index 639febfaf1..16779c4513 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java @@ -24,6 +24,7 @@ package org.hibernate.dialect; import java.sql.Types; +import java.util.Locale; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.sql.CaseFragment; @@ -75,7 +76,7 @@ public class OracleDialect extends Oracle9Dialect { sql = sql.trim(); boolean isForUpdate = false; - if ( sql.toLowerCase().endsWith( " for update" ) ) { + if ( sql.toLowerCase(Locale.ROOT).endsWith( " for update" ) ) { sql = sql.substring( 0, sql.length()-11 ); isForUpdate = true; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java index c8dba6137c..07deee851d 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java @@ -24,6 +24,7 @@ package org.hibernate.dialect; import java.sql.Types; +import java.util.Locale; import org.hibernate.LockMode; import org.hibernate.LockOptions; @@ -73,8 +74,8 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { } static int getAfterSelectInsertPoint(String sql) { - final int selectIndex = sql.toLowerCase().indexOf( "select" ); - final int selectDistinctIndex = sql.toLowerCase().indexOf( "select distinct" ); + final int selectIndex = sql.toLowerCase(Locale.ROOT).indexOf( "select" ); + final int selectDistinctIndex = sql.toLowerCase(Locale.ROOT).indexOf( "select distinct" ); return selectIndex + (selectDistinctIndex == selectIndex ? 15 : 6); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java b/hibernate-core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java index c3bc29dedf..49c29b3430 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java @@ -24,6 +24,7 @@ package org.hibernate.dialect.function; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.hibernate.dialect.Dialect; @@ -56,7 +57,7 @@ public class SQLFunctionRegistry { * @return The located function, maye return {@code null} */ public SQLFunction findSQLFunction(String functionName) { - final String name = functionName.toLowerCase(); + final String name = functionName.toLowerCase(Locale.ROOT); final SQLFunction userFunction = userFunctions.get( name ); return userFunction != null ? userFunction @@ -72,7 +73,7 @@ public class SQLFunctionRegistry { */ @SuppressWarnings("UnusedDeclaration") public boolean hasFunction(String functionName) { - final String name = functionName.toLowerCase(); + final String name = functionName.toLowerCase(Locale.ROOT); return userFunctions.containsKey( name ) || dialect.getFunctions().containsKey( name ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/SQLServer2005LimitHandler.java b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/SQLServer2005LimitHandler.java index d00a755406..fc46eba438 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/SQLServer2005LimitHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/SQLServer2005LimitHandler.java @@ -27,6 +27,7 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -302,7 +303,7 @@ public class SQLServer2005LimitHandler extends AbstractLimitHandler { */ private static int shallowIndexOf(StringBuilder sb, String search, int fromIndex) { // case-insensitive match - final String lowercase = sb.toString().toLowerCase(); + final String lowercase = sb.toString().toLowerCase(Locale.ROOT); final int len = lowercase.length(); final int searchlen = search.length(); int pos = -1; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/BasicFormatterImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/BasicFormatterImpl.java index 7ac399ef11..b753b9b1f9 100755 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/BasicFormatterImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/BasicFormatterImpl.java @@ -25,6 +25,7 @@ package org.hibernate.engine.jdbc.internal; import java.util.HashSet; import java.util.LinkedList; +import java.util.Locale; import java.util.Set; import java.util.StringTokenizer; @@ -126,7 +127,7 @@ public class BasicFormatterImpl implements Formatter { while ( tokens.hasMoreTokens() ) { token = tokens.nextToken(); - lcToken = token.toLowerCase(); + lcToken = token.toLowerCase(Locale.ROOT); if ( "'".equals( token ) ) { String t; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/DDLFormatterImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/DDLFormatterImpl.java index 4a923559d9..a47677f298 100755 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/DDLFormatterImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/DDLFormatterImpl.java @@ -23,6 +23,7 @@ */ package org.hibernate.engine.jdbc.internal; +import java.util.Locale; import java.util.StringTokenizer; import org.hibernate.internal.util.StringHelper; @@ -44,13 +45,13 @@ public class DDLFormatterImpl implements Formatter { if ( StringHelper.isEmpty( sql ) ) { return sql; } - if ( sql.toLowerCase().startsWith( "create table" ) ) { + if ( sql.toLowerCase(Locale.ROOT).startsWith( "create table" ) ) { return formatCreateTable( sql ); } - else if ( sql.toLowerCase().startsWith( "alter table" ) ) { + else if ( sql.toLowerCase(Locale.ROOT).startsWith( "alter table" ) ) { return formatAlterTable( sql ); } - else if ( sql.toLowerCase().startsWith( "comment on" ) ) { + else if ( sql.toLowerCase(Locale.ROOT).startsWith( "comment on" ) ) { return formatCommentOn( sql ); } else { diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/CollectionProperties.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/CollectionProperties.java index 0d6f043034..551b9e1607 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/CollectionProperties.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/CollectionProperties.java @@ -24,6 +24,7 @@ package org.hibernate.hql.internal; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.hibernate.persister.collection.CollectionPropertyNames; @@ -36,17 +37,17 @@ import org.hibernate.persister.collection.CollectionPropertyNames; public final class CollectionProperties { public static final Map HQL_COLLECTION_PROPERTIES; - private static final String COLLECTION_INDEX_LOWER = CollectionPropertyNames.COLLECTION_INDEX.toLowerCase(); + private static final String COLLECTION_INDEX_LOWER = CollectionPropertyNames.COLLECTION_INDEX.toLowerCase(Locale.ROOT); static { HQL_COLLECTION_PROPERTIES = new HashMap(); - HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_ELEMENTS.toLowerCase(), CollectionPropertyNames.COLLECTION_ELEMENTS ); - HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_INDICES.toLowerCase(), CollectionPropertyNames.COLLECTION_INDICES ); - HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_SIZE.toLowerCase(), CollectionPropertyNames.COLLECTION_SIZE ); - HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MAX_INDEX.toLowerCase(), CollectionPropertyNames.COLLECTION_MAX_INDEX ); - HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MIN_INDEX.toLowerCase(), CollectionPropertyNames.COLLECTION_MIN_INDEX ); - HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MAX_ELEMENT.toLowerCase(), CollectionPropertyNames.COLLECTION_MAX_ELEMENT ); - HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MIN_ELEMENT.toLowerCase(), CollectionPropertyNames.COLLECTION_MIN_ELEMENT ); + HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_ELEMENTS.toLowerCase(Locale.ROOT), CollectionPropertyNames.COLLECTION_ELEMENTS ); + HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_INDICES.toLowerCase(Locale.ROOT), CollectionPropertyNames.COLLECTION_INDICES ); + HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_SIZE.toLowerCase(Locale.ROOT), CollectionPropertyNames.COLLECTION_SIZE ); + HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MAX_INDEX.toLowerCase(Locale.ROOT), CollectionPropertyNames.COLLECTION_MAX_INDEX ); + HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MIN_INDEX.toLowerCase(Locale.ROOT), CollectionPropertyNames.COLLECTION_MIN_INDEX ); + HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MAX_ELEMENT.toLowerCase(Locale.ROOT), CollectionPropertyNames.COLLECTION_MAX_ELEMENT ); + HQL_COLLECTION_PROPERTIES.put( CollectionPropertyNames.COLLECTION_MIN_ELEMENT.toLowerCase(Locale.ROOT), CollectionPropertyNames.COLLECTION_MIN_ELEMENT ); HQL_COLLECTION_PROPERTIES.put( COLLECTION_INDEX_LOWER, CollectionPropertyNames.COLLECTION_INDEX ); } @@ -55,7 +56,7 @@ public final class CollectionProperties { @SuppressWarnings("SimplifiableIfStatement") public static boolean isCollectionProperty(String name) { - final String key = name.toLowerCase(); + final String key = name.toLowerCase(Locale.ROOT); // CollectionPropertyMapping processes everything except 'index'. if ( COLLECTION_INDEX_LOWER.equals( key ) ) { return false; @@ -70,7 +71,7 @@ public final class CollectionProperties { } public static boolean isAnyCollectionProperty(String name) { - final String key = name.toLowerCase(); + final String key = name.toLowerCase(Locale.ROOT); return HQL_COLLECTION_PROPERTIES.containsKey( key ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/QuerySplitter.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/QuerySplitter.java index 4c4c66c624..72fdfed136 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/QuerySplitter.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/QuerySplitter.java @@ -26,6 +26,7 @@ package org.hibernate.hql.internal; import java.util.ArrayList; import java.util.HashSet; +import java.util.Locale; import java.util.Set; import org.hibernate.MappingException; @@ -89,7 +90,7 @@ public final class QuerySplitter { int start = getStartingPositionFor( tokens, templateQuery ); int count = 0; String next; - String last = tokens[start - 1].toLowerCase(); + String last = tokens[start - 1].toLowerCase(Locale.ROOT); for ( int i = start; i < tokens.length; i++ ) { @@ -100,12 +101,12 @@ public final class QuerySplitter { continue; } - next = nextNonWhite( tokens, i ).toLowerCase(); + next = nextNonWhite( tokens, i ).toLowerCase(Locale.ROOT); boolean process = isJavaIdentifier( token ) && isPossiblyClassName( last, next ); - last = token.toLowerCase(); + last = token.toLowerCase(Locale.ROOT); if ( process ) { String importedClassName = getImportedClass( token, factory ); @@ -144,13 +145,13 @@ public final class QuerySplitter { private static int getStartingPositionFor(String[] tokens, StringBuilder templateQuery) { templateQuery.append( tokens[0] ); - if ( !"select".equals( tokens[0].toLowerCase() ) ) { + if ( !"select".equals( tokens[0].toLowerCase(Locale.ROOT) ) ) { return 1; } // select-range is terminated by declaration of "from" for ( int i = 1; i < tokens.length; i++ ) { - if ( "from".equals( tokens[i].toLowerCase() ) ) { + if ( "from".equals( tokens[i].toLowerCase(Locale.ROOT) ) ) { return i; } templateQuery.append( tokens[i] ); diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/ConstructorNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/ConstructorNode.java index 80bde63e1c..76885d6bad 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/ConstructorNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/ConstructorNode.java @@ -41,6 +41,7 @@ import org.hibernate.type.Type; import antlr.SemanticException; import antlr.collections.AST; +import java.util.Locale; /** * Represents a constructor (new) in a SELECT. @@ -146,11 +147,11 @@ public class ConstructorNode extends SelectExpressionList implements AggregatedS public void prepare() throws SemanticException { constructorArgumentTypes = resolveConstructorArgumentTypes(); String path = ( (PathNode) getFirstChild() ).getPath(); - if ( "map".equals( path.toLowerCase() ) ) { + if ( "map".equals( path.toLowerCase(Locale.ROOT) ) ) { isMap = true; resultType = Map.class; } - else if ( "list".equals( path.toLowerCase() ) ) { + else if ( "list".equals( path.toLowerCase(Locale.ROOT) ) ) { isList = true; resultType = List.class; } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/MethodNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/MethodNode.java index e2d6df5b3b..a62a48566e 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/MethodNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/MethodNode.java @@ -41,6 +41,7 @@ import org.jboss.logging.Logger; import antlr.SemanticException; import antlr.collections.AST; +import java.util.Locale; /** * Represents a method call. @@ -109,7 +110,7 @@ public class MethodNode extends AbstractSelectExpression implements FunctionNode name.setType( SqlTokenTypes.METHOD_NAME ); String text = name.getText(); // Use the lower case function name. - methodName = text.toLowerCase(); + methodName = text.toLowerCase(Locale.ROOT); // Remember whether we're in a SELECT clause or not. this.inSelect = inSelect; } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/LiteralProcessor.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/LiteralProcessor.java index 669403495b..ef00b2c0d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/LiteralProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/LiteralProcessor.java @@ -51,6 +51,7 @@ import org.jboss.logging.Logger; import antlr.SemanticException; import antlr.collections.AST; +import java.util.Locale; /** * A delegate that handles literals and constants for HqlSqlWalker, performing the token replacement functions and @@ -207,7 +208,7 @@ public class LiteralProcessor implements HqlSqlTokenTypes { constant.setText( replacement ); } else { - boolean bool = "true".equals( constant.getText().toLowerCase() ); + boolean bool = "true".equals( constant.getText().toLowerCase(Locale.ROOT) ); Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect(); constant.setText( dialect.toBooleanValueString( bool ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/ClauseParser.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/ClauseParser.java index de3319fa8c..8f692dce1b 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/ClauseParser.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/ClauseParser.java @@ -25,6 +25,7 @@ package org.hibernate.hql.internal.classic; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import org.hibernate.QueryException; @@ -40,7 +41,7 @@ public class ClauseParser implements Parser { @Override public void token(String token, QueryTranslatorImpl q) throws QueryException { - String lcToken = token.toLowerCase(); + String lcToken = token.toLowerCase(Locale.ROOT); if ( "(".equals( token ) ) { parenCount++; diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/FromParser.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/FromParser.java index ae7a3b1744..bc736eb265 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/FromParser.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/FromParser.java @@ -24,6 +24,7 @@ */ package org.hibernate.hql.internal.classic; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.hibernate.QueryException; @@ -70,7 +71,7 @@ public class FromParser implements Parser { public void token(String token, QueryTranslatorImpl q) throws QueryException { // start by looking for HQL keywords... - String lcToken = token.toLowerCase(); + String lcToken = token.toLowerCase(Locale.ROOT); if ( lcToken.equals( "," ) ) { if ( !( expectingJoin | expectingAs ) ) throw new QueryException( "unexpected token: ," ); expectingJoin = false; diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/PreprocessingParser.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/PreprocessingParser.java index 9a73da7f1f..9dc99864d3 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/PreprocessingParser.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/PreprocessingParser.java @@ -25,6 +25,7 @@ package org.hibernate.hql.internal.classic; import java.util.HashSet; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -107,7 +108,7 @@ public class PreprocessingParser implements Parser { } } else { - String prop = CollectionProperties.getNormalizedPropertyName( token.toLowerCase() ); + String prop = CollectionProperties.getNormalizedPropertyName( token.toLowerCase(Locale.ROOT) ); if ( prop != null ) { currentCollectionProp = prop; return; @@ -123,7 +124,7 @@ public class PreprocessingParser implements Parser { String doubleToken = ( token.length() > 1 ) ? lastToken + ' ' + token : lastToken + token; - if ( HQL_OPERATORS.contains( doubleToken.toLowerCase() ) ) { + if ( HQL_OPERATORS.contains( doubleToken.toLowerCase(Locale.ROOT) ) ) { parser.token( doubleToken, q ); lastToken = null; } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/QueryTranslatorImpl.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/QueryTranslatorImpl.java index ab47f4c1f6..a4002548a3 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/QueryTranslatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/QueryTranslatorImpl.java @@ -37,6 +37,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -750,7 +751,7 @@ public class QueryTranslatorImpl extends BasicLoader implements FilterTranslator parenCount--; } - String lc = token.toLowerCase(); + String lc = token.toLowerCase(Locale.ROOT); if ( lc.equals( ", " ) ) { if ( nolast ) { nolast = false; diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/SelectParser.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/SelectParser.java index f5819addc7..b475830709 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/SelectParser.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/SelectParser.java @@ -26,6 +26,7 @@ package org.hibernate.hql.internal.classic; import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Set; import org.hibernate.QueryException; @@ -75,7 +76,7 @@ public class SelectParser implements Parser { public void token(String token, QueryTranslatorImpl q) throws QueryException { - String lctoken = token.toLowerCase(); + String lctoken = token.toLowerCase(Locale.ROOT); if ( first ) { first = false; diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/WhereParser.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/WhereParser.java index 6f557529d6..16c90faf79 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/WhereParser.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/WhereParser.java @@ -27,6 +27,7 @@ package org.hibernate.hql.internal.classic; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; @@ -210,7 +211,7 @@ public class WhereParser implements Parser { public void token(String token, QueryTranslatorImpl q) throws QueryException { - String lcToken = token.toLowerCase(); + String lcToken = token.toLowerCase(Locale.ROOT); //Cope with [,] if ( token.equals( "[" ) && !expectingPathContinuation ) { @@ -441,7 +442,7 @@ public class WhereParser implements Parser { } else { //anything else - String negatedToken = negated ? ( String ) NEGATIONS.get( token.toLowerCase() ) : null; + String negatedToken = negated ? ( String ) NEGATIONS.get( token.toLowerCase(Locale.ROOT) ) : null; if ( negatedToken != null && ( !betweenSpecialCase || !"or".equals( negatedToken ) ) ) { appendToken( q, negatedToken ); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/StringHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/StringHelper.java index f000726034..a4b2390e55 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/StringHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/StringHelper.java @@ -352,7 +352,7 @@ public final class StringHelper { } public static boolean booleanValue(String tfString) { - String trimmed = tfString.trim().toLowerCase(); + String trimmed = tfString.trim().toLowerCase(Locale.ROOT); return trimmed.equals( "true" ) || trimmed.equals( "t" ); } @@ -549,7 +549,7 @@ public final class StringHelper { String result = truncate( unqualifyEntityName(description), ALIAS_TRUNCATE_LENGTH ) // Important to use Locale.ENGLISH. See HHH-8579. #toLowerCase() uses the default Locale. Certain DBs // do not like non-ascii characters in aliases, etc., so ensure consistency/portability here. - .toLowerCase(Locale.ENGLISH) + .toLowerCase(Locale.ROOT) .replace( '/', '_' ) // entityNames may now include slashes for the representations .replace( '$', '_' ); //classname may be an inner class result = cleanAlias( result ); @@ -593,13 +593,13 @@ public final class StringHelper { } public static String toUpperCase(String str) { - return str==null ? null : str.toUpperCase(); + return str==null ? null : str.toUpperCase(Locale.ROOT); } public static String toLowerCase(String str) { // Important to use Locale.ENGLISH. See HHH-8579. #toLowerCase() uses the default Locale. Certain DBs do not // like non-ascii characters in aliases, etc., so ensure consistency/portability here. - return str == null ? null : str.toLowerCase(Locale.ENGLISH); + return str == null ? null : str.toLowerCase(Locale.ROOT); } public static String moveAndToBeginning(String filter) { diff --git a/hibernate-core/src/main/java/org/hibernate/loader/BatchFetchStyle.java b/hibernate-core/src/main/java/org/hibernate/loader/BatchFetchStyle.java index a429408cec..a892d0725b 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/BatchFetchStyle.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/BatchFetchStyle.java @@ -23,6 +23,7 @@ */ package org.hibernate.loader; +import java.util.Locale; import org.jboss.logging.Logger; /** @@ -60,7 +61,7 @@ public enum BatchFetchStyle { private static final Logger log = Logger.getLogger( BatchFetchStyle.class ); public static BatchFetchStyle byName(String name) { - return valueOf( name.toUpperCase() ); + return valueOf( name.toUpperCase(Locale.ROOT) ); } public static BatchFetchStyle interpret(Object setting) { diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java index 6ef249f91d..539f8feb3f 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java @@ -23,6 +23,7 @@ */ package org.hibernate.mapping; import java.io.Serializable; +import java.util.Locale; import org.hibernate.HibernateException; import org.hibernate.MappingException; @@ -122,7 +123,7 @@ public class Column implements Selectable, Serializable, Cloneable { } boolean useRawName = name.length() + suffix.length() <= dialect.getMaxAliasLength() - && !quoted && !name.toLowerCase().equals( "rowid" ); + && !quoted && !name.toLowerCase(Locale.ROOT).equals( "rowid" ); if ( !useRawName ) { if ( suffix.length() >= dialect.getMaxAliasLength() ) { throw new MappingException( String.format( @@ -168,7 +169,7 @@ public class Column implements Selectable, Serializable, Cloneable { //used also for generation of FK names! return isQuoted() ? name.hashCode() : - name.toLowerCase().hashCode(); + name.toLowerCase(Locale.ROOT).hashCode(); } @Override @@ -345,7 +346,7 @@ public class Column implements Selectable, Serializable, Cloneable { } public String getCanonicalName() { - return quoted ? name : name.toLowerCase(); + return quoted ? name : name.toLowerCase(Locale.ROOT); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java index 00aa77fcbb..3e7db34fe2 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java @@ -29,6 +29,7 @@ import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import org.hibernate.HibernateException; @@ -365,15 +366,15 @@ public class Table implements RelationalModel, Serializable { throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName())); } else { - final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase() - .startsWith( columnInfo.getTypeName().toLowerCase() ) + final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase(Locale.ROOT) + .startsWith( columnInfo.getTypeName().toLowerCase(Locale.ROOT) ) || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) + " for column " + col.getName() + - ". Found: " + columnInfo.getTypeName().toLowerCase() + + ". Found: " + columnInfo.getTypeName().toLowerCase(Locale.ROOT) + ", expected: " + col.getSqlType( dialect, mapping ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/Template.java b/hibernate-core/src/main/java/org/hibernate/sql/Template.java index baca2b2fee..060c72f0e2 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/Template.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/Template.java @@ -27,6 +27,7 @@ package org.hibernate.sql; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.StringTokenizer; @@ -165,7 +166,7 @@ public final class Template { String nextToken = hasMore ? tokens.nextToken() : null; while ( hasMore ) { String token = nextToken; - String lcToken = token.toLowerCase(); + String lcToken = token.toLowerCase(Locale.ROOT); hasMore = tokens.hasMoreTokens(); nextToken = hasMore ? tokens.nextToken() : null; @@ -378,7 +379,7 @@ public final class Template { // String nextToken = hasMore ? tokens.nextToken() : null; // while ( hasMore ) { // String token = nextToken; -// String lcToken = token.toLowerCase(); +// String lcToken = token.toLowerCase(Locale.ROOT); // hasMore = tokens.hasMoreTokens(); // nextToken = hasMore ? tokens.nextToken() : null; // diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/UniqueConstraintSchemaUpdateStrategy.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/UniqueConstraintSchemaUpdateStrategy.java index 24b5c451a6..270775d021 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/UniqueConstraintSchemaUpdateStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/UniqueConstraintSchemaUpdateStrategy.java @@ -20,6 +20,7 @@ */ package org.hibernate.tool.hbm2ddl; +import java.util.Locale; import org.jboss.logging.Logger; /** @@ -61,7 +62,7 @@ public enum UniqueConstraintSchemaUpdateStrategy { private static final Logger log = Logger.getLogger( UniqueConstraintSchemaUpdateStrategy.class ); public static UniqueConstraintSchemaUpdateStrategy byName(String name) { - return valueOf( name.toUpperCase() ); + return valueOf( name.toUpperCase(Locale.ROOT) ); } public static UniqueConstraintSchemaUpdateStrategy interpret(Object setting) { diff --git a/hibernate-core/src/test/java/org/hibernate/dialect/SQLServer2005DialectTestCase.java b/hibernate-core/src/test/java/org/hibernate/dialect/SQLServer2005DialectTestCase.java index 35aa9cf8c1..63a30e268d 100644 --- a/hibernate-core/src/test/java/org/hibernate/dialect/SQLServer2005DialectTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/dialect/SQLServer2005DialectTestCase.java @@ -23,13 +23,14 @@ */ package org.hibernate.dialect; +import org.hibernate.engine.spi.RowSelection; +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.hibernate.engine.spi.RowSelection; -import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; +import java.util.Locale; import static org.junit.Assert.assertEquals; @@ -60,7 +61,7 @@ public class SQLServer2005DialectTestCase extends BaseUnitTestCase { "with query as (select inner_query.*, row_number() over (order by current_timestamp) as __hibernate_row_nr__ from ( " + "select distinct top(?) f1 as f53245 from table849752 order by f234, f67 desc ) inner_query )" + " select f53245 from query where __hibernate_row_nr__ >= ? and __hibernate_row_nr__ < ?", - dialect.buildLimitHandler( input, toRowSelection( 10, 15 ) ).getProcessedSql().toLowerCase() + dialect.buildLimitHandler( input, toRowSelection( 10, 15 ) ).getProcessedSql().toLowerCase(Locale.ROOT) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/dataTypes/BasicOperationsTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/dataTypes/BasicOperationsTest.java index 990bcd8728..ae871bddc7 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/dataTypes/BasicOperationsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/dataTypes/BasicOperationsTest.java @@ -29,6 +29,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Date; +import java.util.Locale; import org.junit.Test; @@ -142,7 +143,7 @@ public class BasicOperationsTest extends BaseCoreFunctionalTestCase { private String generateFinalNamePattern(DatabaseMetaData meta, String name) throws SQLException { if ( meta.storesLowerCaseIdentifiers() ) { - return name.toLowerCase(); + return name.toLowerCase(Locale.ROOT); } else { return name; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java index f7c7e2dbb2..bba08bf73e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java @@ -35,6 +35,7 @@ import java.util.Currency; import java.util.Date; import java.util.HashSet; import java.util.Iterator; +import java.util.Locale; import java.util.Set; import org.hibernate.AnnotationException; @@ -525,8 +526,8 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase { s = openSession(); tx = s.beginTransaction(); Forest f2 = (Forest) s.get( Forest.class, f.getId() ); - assertEquals( f.getSmallText().toLowerCase(), f2.getSmallText() ); - assertEquals( f.getBigText().toUpperCase(), f2.getBigText() ); + assertEquals( f.getSmallText().toLowerCase(Locale.ROOT), f2.getSmallText() ); + assertEquals( f.getBigText().toUpperCase(Locale.ROOT), f2.getBigText() ); tx.commit(); s.close(); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/CasterStringType.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/CasterStringType.java index 37f32503f3..d2fe9942d2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/CasterStringType.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/CasterStringType.java @@ -5,6 +5,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; +import java.util.Locale; import java.util.Properties; import org.hibernate.HibernateException; @@ -41,10 +42,10 @@ public class CasterStringType implements UserType, ParameterizedType { String result = rs.getString( names[0] ); if ( rs.wasNull() ) return null; if ( parameters.getProperty( CAST ).equals( "lower" ) ) { - return result.toLowerCase(); + return result.toLowerCase(Locale.ROOT); } else { - return result.toUpperCase(); + return result.toUpperCase(Locale.ROOT); } } @@ -55,10 +56,10 @@ public class CasterStringType implements UserType, ParameterizedType { else { String string = (String) value; if ( parameters.getProperty( CAST ).equals( "lower" ) ) { - string = string.toLowerCase(); + string = string.toLowerCase(Locale.ROOT); } else { - string = string.toUpperCase(); + string = string.toUpperCase(Locale.ROOT); } st.setString( index, string ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/join/JoinTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/join/JoinTest.java index 187c6717c3..5272b1f6ac 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/join/JoinTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/join/JoinTest.java @@ -25,6 +25,7 @@ package org.hibernate.test.annotations.join; import java.util.ArrayList; import java.util.Date; +import java.util.Locale; import org.junit.Test; @@ -216,7 +217,7 @@ public class JoinTest extends BaseCoreFunctionalTestCase { s.clear(); Cat c = (Cat) s.get( Cat.class, cat.getId() ); - assertEquals( storyPart2.toUpperCase(), c.getStoryPart2() ); + assertEquals( storyPart2.toUpperCase(Locale.ROOT), c.getStoryPart2() ); tx.rollback(); s.close(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java index 3c2c45a2d3..7a057fc0e5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java @@ -1,6 +1,8 @@ // $Id$ package org.hibernate.test.annotations.namingstrategy; +import org.junit.Before; + import java.io.PrintWriter; import java.io.StringWriter; import java.util.Iterator; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java index 7f358a4b12..ad82f744ef 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java @@ -28,6 +28,7 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; +import java.util.Locale; import org.junit.Test; @@ -397,7 +398,7 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase { chaos.setId( 1l ); String lowerName = "hello"; - String upperName = lowerName.toUpperCase(); + String upperName = lowerName.toUpperCase(Locale.ROOT); assertFalse( lowerName.equals( upperName ) ); chaos.setName( "hello" ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java index 590691265b..7eadae1682 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java @@ -25,6 +25,7 @@ package org.hibernate.test.interceptor; import java.io.Serializable; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Queue; import org.junit.Test; @@ -296,8 +297,8 @@ public class InterceptorTest extends BaseCoreFunctionalTestCase { @Override public String onPrepareStatement(String sql) { assertNotNull( sql ); - String expectedSql = expectedSQLs.poll().toLowerCase(); - assertTrue("sql:\n " + sql.toLowerCase() +"\n doesn't start with \n"+expectedSql+"\n", sql.toLowerCase().startsWith( expectedSql ) ); + String expectedSql = expectedSQLs.poll().toLowerCase(Locale.ROOT); + assertTrue("sql:\n " + sql.toLowerCase(Locale.ROOT) +"\n doesn't start with \n"+expectedSql+"\n", sql.toLowerCase(Locale.ROOT).startsWith( expectedSql ) ); return sql; } }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/lazycache/Document.java b/hibernate-core/src/test/java/org/hibernate/test/lazycache/Document.java index 8910391b13..9bb20c6ac6 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/lazycache/Document.java +++ b/hibernate-core/src/test/java/org/hibernate/test/lazycache/Document.java @@ -1,6 +1,7 @@ //$Id: Document.java 7772 2005-08-05 23:03:46Z oneovthafew $ package org.hibernate.test.lazycache; import java.util.Date; +import java.util.Locale; /** * @author Gavin King @@ -17,7 +18,7 @@ public class Document { public Document(String name, String summary, String text) { lastTextModification = new Date(); this.name = name; - upperCaseName = name.toUpperCase(); + upperCaseName = name.toUpperCase(Locale.ROOT); this.summary = summary; this.text = text; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java index c56710181b..e2a3fdc2ca 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/legacy/FooBarTest.java @@ -1950,7 +1950,7 @@ public class FooBarTest extends LegacyTestCase { List list = s.createCriteria(Foo.class) .add( Restrictions.eq( "integer", f.getInteger() ) ) .add( Restrictions.eqProperty("integer", "integer") ) - .add( Restrictions.like( "string", f.getString().toUpperCase() ).ignoreCase() ) + .add( Restrictions.like( "string", f.getString().toUpperCase(Locale.ROOT) ).ignoreCase() ) .add( Restrictions.in( "boolean", new Boolean[] { f.getBoolean(), f.getBoolean() } ) ) .setFetchMode("foo", FetchMode.JOIN) .setFetchMode("baz", FetchMode.SELECT) diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/StringComparator.java b/hibernate-core/src/test/java/org/hibernate/test/legacy/StringComparator.java index 960de0cb72..405a8c84e3 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/StringComparator.java +++ b/hibernate-core/src/test/java/org/hibernate/test/legacy/StringComparator.java @@ -1,11 +1,12 @@ package org.hibernate.test.legacy; import java.io.Serializable; import java.util.Comparator; +import java.util.Locale; public class StringComparator implements Comparator, Serializable { public int compare(Object o1, Object o2) { - return ( (String) o1 ).toLowerCase().compareTo( ( (String) o2 ).toLowerCase() ); + return ( (String) o1 ).toLowerCase(Locale.ROOT).compareTo( ( (String) o2 ).toLowerCase(Locale.ROOT) ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/manytomany/batchload/BatchedManyToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/manytomany/batchload/BatchedManyToManyTest.java index 5ee397b82b..811a8f9726 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/manytomany/batchload/BatchedManyToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/manytomany/batchload/BatchedManyToManyTest.java @@ -24,6 +24,7 @@ package org.hibernate.test.manytomany.batchload; import java.util.List; +import java.util.Locale; import org.hibernate.EmptyInterceptor; import org.hibernate.Hibernate; @@ -97,7 +98,7 @@ public class BatchedManyToManyTest extends BaseCoreFunctionalTestCase { // of dialects... Assert.assertFalse( "batch load of many-to-many should use inner join", - sql.toLowerCase().contains( "left outer join" ) + sql.toLowerCase(Locale.ROOT).contains( "left outer join" ) ); return super.onPrepareStatement( sql ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java b/hibernate-core/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java index 2d89ad71c0..42f30eb7ae 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/sql/hand/query/NativeSQLQueriesTest.java @@ -13,6 +13,7 @@ import java.math.BigInteger; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import org.hibernate.Hibernate; @@ -902,7 +903,7 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase { for ( int i = 0; i < tuple.length; i++ ) { String alias = aliases[i]; if ( alias != null ) { - result.put( alias.toUpperCase(), tuple[i] ); + result.put( alias.toUpperCase(Locale.ROOT), tuple[i] ); } } return result; diff --git a/hibernate-core/src/test/java/org/hibernate/test/stateless/fetching/StatelessSessionFetchingTest.java b/hibernate-core/src/test/java/org/hibernate/test/stateless/fetching/StatelessSessionFetchingTest.java index 391268320d..7ba29f075c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/stateless/fetching/StatelessSessionFetchingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/stateless/fetching/StatelessSessionFetchingTest.java @@ -24,6 +24,7 @@ package org.hibernate.test.stateless.fetching; import java.util.Date; +import java.util.Locale; import org.jboss.logging.Logger; import org.junit.Test; @@ -95,7 +96,7 @@ public class StatelessSessionFetchingTest extends BaseCoreFunctionalTestCase { } private String determineUniquePrefix() { - return StringHelper.collapseQualifier( getClass().getName(), false ).toUpperCase(); + return StringHelper.collapseQualifier( getClass().getName(), false ).toUpperCase(Locale.ROOT); } } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/function/ParameterizedFunctionExpression.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/function/ParameterizedFunctionExpression.java index 2027a3cdb9..138d325fc2 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/function/ParameterizedFunctionExpression.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/function/ParameterizedFunctionExpression.java @@ -25,6 +25,7 @@ package org.hibernate.jpa.criteria.expression.function; import java.util.Arrays; import java.util.List; +import java.util.Locale; import javax.persistence.criteria.Expression; import org.hibernate.jpa.criteria.CriteriaBuilderImpl; @@ -73,7 +74,7 @@ public class ParameterizedFunctionExpression List> argumentExpressions) { super( criteriaBuilder, javaType, functionName ); this.argumentExpressions = argumentExpressions; - this.isStandardJpaFunction = STANDARD_JPA_FUNCTION_NAMES.contains( functionName.toUpperCase() ); + this.isStandardJpaFunction = STANDARD_JPA_FUNCTION_NAMES.contains( functionName.toUpperCase(Locale.ROOT) ); } public ParameterizedFunctionExpression( @@ -83,7 +84,7 @@ public class ParameterizedFunctionExpression Expression... argumentExpressions) { super( criteriaBuilder, javaType, functionName ); this.argumentExpressions = Arrays.asList( argumentExpressions ); - this.isStandardJpaFunction = STANDARD_JPA_FUNCTION_NAMES.contains( functionName.toUpperCase() ); + this.isStandardJpaFunction = STANDARD_JPA_FUNCTION_NAMES.contains( functionName.toUpperCase(Locale.ROOT) ); } protected boolean isStandardJpaFunction() { diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/util/ConfigurationHelper.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/util/ConfigurationHelper.java index c8050625e8..be4f5b9902 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/util/ConfigurationHelper.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/util/ConfigurationHelper.java @@ -23,6 +23,7 @@ */ package org.hibernate.jpa.internal.util; +import java.util.Locale; import java.util.Map; import java.util.Properties; import javax.persistence.FlushModeType; @@ -65,7 +66,7 @@ public abstract class ConfigurationHelper { if (flushMode == null) { return null; } - flushMode = flushMode.toUpperCase(); + flushMode = flushMode.toUpperCase(Locale.ROOT); return FlushMode.valueOf( flushMode ); } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/util/XmlHelper.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/util/XmlHelper.java index ad3a481389..af6046cd8d 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/util/XmlHelper.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/util/XmlHelper.java @@ -23,6 +23,7 @@ package org.hibernate.jpa.internal.util; import java.util.ArrayList; import java.util.Iterator; +import java.util.Locale; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -192,7 +193,7 @@ public final class XmlHelper { public static boolean getOptionalChildBooleanContent(Element element, String name) throws Exception { Element child = getOptionalChild( element, name ); if ( child != null ) { - String value = getElementContent( child ).toLowerCase(); + String value = getElementContent( child ).toLowerCase(Locale.ROOT); return value.equals( "true" ) || value.equals( "yes" ); } diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metadata/MetadataTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metadata/MetadataTest.java index f700de9e36..90d374a4ee 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metadata/MetadataTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/metadata/MetadataTest.java @@ -24,6 +24,7 @@ package org.hibernate.jpa.test.metadata; import java.util.Collections; +import java.util.Locale; import java.util.Set; import javax.persistence.EntityManagerFactory; import javax.persistence.metamodel.Attribute; @@ -408,7 +409,7 @@ public class MetadataTest extends BaseEntityManagerFunctionalTestCase { for (Attribute attribute : safeAttributes ) { final String name = attribute.getJavaMember().getName(); assertNotNull( attribute.getJavaMember() ); - assertTrue( name.toLowerCase().endsWith( attribute.getName().toLowerCase() ) ); + assertTrue( name.toLowerCase(Locale.ROOT).endsWith( attribute.getName().toLowerCase(Locale.ROOT) ) ); } } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/internal/IlikeAuditExpression.java b/hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/internal/IlikeAuditExpression.java index a2647a6132..0de7225246 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/internal/IlikeAuditExpression.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/query/criteria/internal/IlikeAuditExpression.java @@ -7,6 +7,8 @@ import org.hibernate.envers.internal.tools.query.QueryBuilder; import org.hibernate.envers.query.criteria.AuditCriterion; import org.hibernate.envers.query.internal.property.PropertyNameGetter; +import java.util.Locale; + public class IlikeAuditExpression implements AuditCriterion { private PropertyNameGetter propertyNameGetter; @@ -28,7 +30,7 @@ public class IlikeAuditExpression implements AuditCriterion { propertyNameGetter); CriteriaTools.checkPropertyNotARelation( auditCfg, entityName, propertyName ); - parameters.addWhereWithFunction( propertyName, " lower ", " like ", value.toLowerCase() ); + parameters.addWhereWithFunction( propertyName, " lower ", " like ", value.toLowerCase(Locale.ROOT) ); } } diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/StringUtil.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/StringUtil.java index 6eaaf2c586..dad3f40c15 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/StringUtil.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/StringUtil.java @@ -23,6 +23,8 @@ */ package org.hibernate.jpamodelgen.util; +import java.util.Locale; + /** * @author Hardy Ferentschik */ @@ -104,7 +106,7 @@ public final class StringUtil { return string; } else { - return string.substring( 0, 1 ).toLowerCase() + string.substring( 1 ); + return string.substring( 0, 1 ).toLowerCase(Locale.ROOT) + string.substring( 1 ); } }