diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java index 499b61ac35..26dfafd770 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java @@ -728,7 +728,7 @@ public class H2LegacyDialect extends Dialect { if ( idx > 0 ) { String constraintName = message.substring( idx + "violation: ".length() ); if ( sqle.getSQLState().equals( "23506" ) ) { - constraintName = constraintName.substring( 1, constraintName.indexOf( ":" ) ); + constraintName = constraintName.substring( 1, constraintName.indexOf( ':' ) ); } return constraintName; } diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacyDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacyDialect.java index 8d85234801..0deb8321d3 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacyDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacyDialect.java @@ -677,7 +677,7 @@ public class SQLServerLegacyDialect extends AbstractTransactSQLDialect { final StringBuilder buffer = new StringBuilder( sql.length() + hints.length() + 12 ); - final int pos = sql.indexOf( ";" ); + final int pos = sql.indexOf( ';' ); if ( pos > -1 ) { buffer.append( sql, 0, pos ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java index b0dc94f66e..b3e1b2c290 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/InferredBasicValueResolver.java @@ -256,7 +256,7 @@ public class InferredBasicValueResolver { if ( jdbcMapping == null ) { throw new MappingException( - "Could not determine JavaType nor JdbcType to use" + "" + + "Could not determine JavaType nor JdbcType to use" + " for " + ( (BasicValue) stdIndicators ).getResolvedJavaType() + "; table = " + table.getName() + "; column = " + selectable.getText() diff --git a/hibernate-core/src/main/java/org/hibernate/boot/query/SqlResultSetMappingDescriptor.java b/hibernate-core/src/main/java/org/hibernate/boot/query/SqlResultSetMappingDescriptor.java index 519e8f1f78..527a2a8da3 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/query/SqlResultSetMappingDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/query/SqlResultSetMappingDescriptor.java @@ -407,7 +407,7 @@ public class SqlResultSetMappingDescriptor implements NamedResultSetMappingDescr } else if( subPart instanceof EmbeddedAttributeMapping ){ final ModelPart subPart1 = ( (EmbeddedAttributeMapping) subPart ).findSubPart( propertyPath.substring( - propertyPath.indexOf( "." ) + 1), null ); + propertyPath.indexOf( '.' ) + 1), null ); return getFetchMemento( navigablePath,subPart1 ); } throw new UnsupportedOperationException( diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index 3c5034a716..a7864d43b7 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -734,7 +734,7 @@ public class H2Dialect extends Dialect { if ( idx > 0 ) { String constraintName = message.substring( idx + "violation: ".length() ); if ( sqle.getSQLState().equals( "23506" ) ) { - constraintName = constraintName.substring( 1, constraintName.indexOf( ":" ) ); + constraintName = constraintName.substring( 1, constraintName.indexOf( ':' ) ); } return constraintName; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java index 494d15a92f..bae8aa4b94 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java @@ -405,15 +405,13 @@ public class PostgreSQLDialect extends Dialect { separator = ","; } type.append( ')' ); - StringBuilder cast1 = new StringBuilder(); - cast1.append("create cast (varchar as " ) - .append( name ) - .append( ") with inout as implicit" ); - StringBuilder cast2 = new StringBuilder(); - cast2.append("create cast (" ) - .append( name ) - .append( " as varchar) with inout as implicit" ); - return new String[] { type.toString(), cast1.toString(), cast2.toString() }; + String cast1 = "create cast (varchar as " + + name + + ") with inout as implicit"; + String cast2 = "create cast (" + + name + + " as varchar) with inout as implicit"; + return new String[] { type.toString(), cast1, cast2 }; } @Override 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 1e82aa16d5..47b22e44cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java @@ -670,7 +670,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { final StringBuilder buffer = new StringBuilder( sql.length() + hints.length() + 12 ); - final int pos = sql.indexOf( ";" ); + final int pos = sql.indexOf( ';' ); if ( pos > -1 ) { buffer.append( sql, 0, pos ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/aggregate/OracleAggregateSupport.java b/hibernate-core/src/main/java/org/hibernate/dialect/aggregate/OracleAggregateSupport.java index eacb4e67b4..81da65cdb3 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/aggregate/OracleAggregateSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/aggregate/OracleAggregateSupport.java @@ -111,7 +111,7 @@ public class OracleAggregateSupport extends AggregateSupportImpl { case BIGINT: return template.replace( placeholder, - "" + aggregateParentReadExpression + "." + column + ".number()" + aggregateParentReadExpression + "." + column + ".number()" ); case DATE: return template.replace( diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/hint/IndexQueryHintHandler.java b/hibernate-core/src/main/java/org/hibernate/dialect/hint/IndexQueryHintHandler.java index bee363054a..9a70d55678 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/hint/IndexQueryHintHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/hint/IndexQueryHintHandler.java @@ -34,12 +34,11 @@ public class IndexQueryHintHandler implements QueryHintHandler { String startToken = matcher.group( 1 ); String endToken = matcher.group( 2 ); - return new StringBuilder( startToken ) - .append( " use index (" ) - .append( hints ) - .append( ") " ) - .append( endToken ) - .toString(); + return startToken + + " use index (" + + hints + + ") " + + endToken; } else { return query; diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/Oracle12LimitHandler.java b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/Oracle12LimitHandler.java index 84b12bf7b6..5503d9ae52 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/Oracle12LimitHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/Oracle12LimitHandler.java @@ -85,7 +85,7 @@ public class Oracle12LimitHandler extends AbstractLimitHandler { } offsetFetchLength = sql.length() + offsetFetchString.length(); - return new StringBuilder( offsetFetchLength ).append( sql ).append( offsetFetchString ).toString(); + return sql + offsetFetchString; } protected String processSql(String sql, int forUpdateIndex, boolean hasFirstRow) { @@ -136,7 +136,7 @@ public class Oracle12LimitHandler extends AbstractLimitHandler { private int getForUpdateIndex(String sql) { final int forUpdateLastIndex = sql.toLowerCase( Locale.ROOT ).lastIndexOf( "for update" ); // We need to recognize cases like : select a from t where b = 'for update'; - final int lastIndexOfQuote = sql.lastIndexOf( "'" ); + final int lastIndexOfQuote = sql.lastIndexOf( '\'' ); if ( forUpdateLastIndex > -1 ) { if ( lastIndexOfQuote == -1 ) { return forUpdateLastIndex; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java index 65d1551f13..cd24deb515 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java @@ -857,7 +857,7 @@ public class MappingModelCreationHelper { } if ( referencedPropertyName != null ) { - if ( referencedPropertyName.indexOf( "." ) > 0 ) { + if ( referencedPropertyName.indexOf( '.' ) > 0 ) { return interpretNestedToOneKeyDescriptor( referencedEntityDescriptor, referencedPropertyName, diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/StandardHqlTranslator.java b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/StandardHqlTranslator.java index 191b597aad..342163bdad 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/StandardHqlTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/StandardHqlTranslator.java @@ -172,7 +172,7 @@ public class StandardHqlTranslator implements HqlTranslator { errorText += ", "; } if ( e instanceof NoViableAltException ) { - errorText += message.substring( 0, message.indexOf("'") ); + errorText += message.substring( 0, message.indexOf( '\'' ) ); if ( hql.isEmpty() ) { errorText += "'*' (empty query string)"; } 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 e639c35e50..2543390f87 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/Template.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/Template.java @@ -130,12 +130,10 @@ public final class Template { // which the tokens occur. Depending on the state of those flags we decide whether we need to qualify // identifier references. - String symbols = new StringBuilder() - .append( PUNCTUATION ) - .append( WHITESPACE ) - .append( dialect.openQuote() ) - .append( dialect.closeQuote() ) - .toString(); + String symbols = PUNCTUATION + + WHITESPACE + + dialect.openQuote() + + dialect.closeQuote(); StringTokenizer tokens = new StringTokenizer( sqlWhereString, symbols, true ); StringBuilder result = new StringBuilder(); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java index 1bcb7dcd2d..9d2cd405b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java @@ -8186,7 +8186,7 @@ public abstract class AbstractSqlAstTranslator implemen int lastEnd = 0; for ( ColumnValueParameter parameter : columnWriteFragment.getParameters() ) { - final int markerStart = sqlFragment.indexOf( "?", lastEnd ); + final int markerStart = sqlFragment.indexOf( '?', lastEnd ); // append the part of the fragment from the last-end position (start of string for first pass) // to the index of the parameter marker diff --git a/hibernate-core/src/main/java/org/hibernate/stat/internal/CacheRegionStatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/internal/CacheRegionStatisticsImpl.java index f5f1d4ea99..23d18d5703 100644 --- a/hibernate-core/src/main/java/org/hibernate/stat/internal/CacheRegionStatisticsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/internal/CacheRegionStatisticsImpl.java @@ -87,15 +87,15 @@ public class CacheRegionStatisticsImpl implements CacheRegionStatistics, Seriali @Override public String toString() { - StringBuilder buf = new StringBuilder().append( "CacheRegionStatistics" ) - .append( "[region=").append( region.getName() ) - .append( ",hitCount=").append( this.hitCount ) - .append( ",missCount=").append( this.missCount ) - .append( ",putCount=").append( this.putCount ) - .append( ",elementCountInMemory=" ).append( this.getElementCountInMemory() ) - .append( ",elementCountOnDisk=" ).append( this.getElementCountOnDisk() ) - .append( ",sizeInMemory=" ).append( this.getSizeInMemory() ) - .append( ']' ); - return buf.toString(); + String buf = "CacheRegionStatistics" + + "[region=" + region.getName() + + ",hitCount=" + this.hitCount + + ",missCount=" + this.missCount + + ",putCount=" + this.putCount + + ",elementCountInMemory=" + this.getElementCountInMemory() + + ",elementCountOnDisk=" + this.getElementCountOnDisk() + + ",sizeInMemory=" + this.getSizeInMemory() + + ']'; + return buf; } } diff --git a/hibernate-core/src/main/java/org/hibernate/stat/internal/SessionStatisticsImpl.java b/hibernate-core/src/main/java/org/hibernate/stat/internal/SessionStatisticsImpl.java index 3c8825c978..11f563903a 100644 --- a/hibernate-core/src/main/java/org/hibernate/stat/internal/SessionStatisticsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/stat/internal/SessionStatisticsImpl.java @@ -40,12 +40,10 @@ public class SessionStatisticsImpl implements SessionStatistics { } public String toString() { - return new StringBuilder() - .append("SessionStatistics[") - .append("entity count=").append( getEntityCount() ) - .append(",collection count=").append( getCollectionCount() ) - .append(']') - .toString(); + return "SessionStatistics[" + + "entity count=" + getEntityCount() + + ",collection count=" + getCollectionCount() + + ']'; } } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/StringTools.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/StringTools.java index c8e8a91b46..1d975d3c79 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/StringTools.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/StringTools.java @@ -32,7 +32,7 @@ public abstract class StringTools { if ( s == null ) { return null; } - final int lastDot = s.lastIndexOf( "." ); + final int lastDot = s.lastIndexOf( '.' ); if ( lastDot == -1 ) { return s; } diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/ImportContextImpl.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/ImportContextImpl.java index 936edc2573..83c9cc7b4d 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/ImportContextImpl.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/ImportContextImpl.java @@ -127,7 +127,7 @@ public class ImportContextImpl implements ImportContext { } private boolean inDefaultPackage(String className) { - return className.indexOf( "." ) < 0; + return className.indexOf( '.' ) < 0; } private boolean isPrimitive(String className) { @@ -175,7 +175,7 @@ public class ImportContextImpl implements ImportContext { } public static String qualifier(String qualifiedName) { - int loc = qualifiedName.lastIndexOf( "." ); + int loc = qualifiedName.lastIndexOf( '.' ); return ( loc < 0 ) ? "" : qualifiedName.substring( 0, loc ); } }