From 4499abd9a911ca38cfbd4f1638d19592467e9b77 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Thu, 3 Sep 2020 15:35:50 +0800 Subject: [PATCH 01/16] Replace StringBuffer with StringBuilder avoid unnecessary synchronization --- .../hibernate/cfg/DefaultComponentSafeNamingStrategy.java | 3 +-- .../main/java/org/hibernate/cfg/DefaultNamingStrategy.java | 3 +-- .../src/main/java/org/hibernate/cfg/EJB3NamingStrategy.java | 3 +-- .../main/java/org/hibernate/cfg/ImprovedNamingStrategy.java | 3 +-- .../hibernate/hql/internal/classic/QueryTranslatorImpl.java | 2 +- .../org/hibernate/jpa/test/criteria/idclass/WidgetId.java | 2 +- .../org/hibernate/jpa/test/pack/defaultpar/Version.java | 2 +- .../hibernate/jpa/test/pack/defaultpar_1_0/Version1.java | 2 +- .../test/java/org/hibernate/jpa/test/pack/war/Version.java | 2 +- .../test/annotations/AlternativeNamingStrategy.java | 3 +-- .../spatial/dialect/oracle/GetDimensionFunction.java | 2 +- .../spatial/dialect/oracle/GetGeometryTypeFunction.java | 2 +- .../hibernate/spatial/dialect/oracle/OracleSDOSupport.java | 6 +++--- .../spatial/dialect/oracle/OracleSpatialFunctions.java | 4 ++-- .../hibernate/spatial/dialect/oracle/SDOObjectMethod.java | 2 +- .../hibernate/spatial/dialect/oracle/SDOObjectProperty.java | 2 +- .../dialect/oracle/criterion/OracleSpatialProjection.java | 2 +- .../spatial/dialect/sqlserver/SqlServerMethod.java | 2 +- 18 files changed, 21 insertions(+), 26 deletions(-) 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 da7d7054d9..25da374d76 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java @@ -61,8 +61,7 @@ public class DefaultComponentSafeNamingStrategy extends EJB3NamingStrategy { return tableName; } else { - //use of a stringbuffer to workaround a JDK bug - return new StringBuffer( ownerEntityTable ).append( "_" ) + return new StringBuilder( ownerEntityTable ).append( "_" ) .append( associatedEntityTable != null ? associatedEntityTable : diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java b/hibernate-core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java index afdf979652..c184a279b3 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java @@ -96,8 +96,7 @@ public class DefaultNamingStrategy implements NamingStrategy, Serializable { return tableName; } else { - //use of a stringbuffer to workaround a JDK bug - return new StringBuffer(ownerEntityTable).append("_") + return new StringBuilder(ownerEntityTable).append("_") .append( associatedEntityTable != null ? associatedEntityTable : diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/EJB3NamingStrategy.java b/hibernate-core/src/main/java/org/hibernate/cfg/EJB3NamingStrategy.java index 3b075ca6a3..bbeab2347c 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/EJB3NamingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/EJB3NamingStrategy.java @@ -72,8 +72,7 @@ public class EJB3NamingStrategy implements NamingStrategy, Serializable { return tableName; } else { - //use of a stringbuffer to workaround a JDK bug - return new StringBuffer( ownerEntityTable ).append( "_" ) + return new StringBuilder( ownerEntityTable ).append( "_" ) .append( associatedEntityTable != null ? associatedEntityTable : 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 6487416f94..0b266cd84d 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java @@ -110,8 +110,7 @@ public class ImprovedNamingStrategy implements NamingStrategy, Serializable { return tableName; } else { - //use of a stringbuffer to workaround a JDK bug - return new StringBuffer(ownerEntityTable).append("_") + return new StringBuilder(ownerEntityTable).append("_") .append( associatedEntityTable != null ? associatedEntityTable : 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 ab68bd667b..11fe2c5f2f 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 @@ -771,7 +771,7 @@ public class QueryTranslatorImpl extends BasicLoader implements FilterTranslator } /*private String renderOrderByPropertiesSelect() { - StringBuffer buf = new StringBuffer(10); + StringBuilder buf = new StringBuilder(10); //add the columns we are ordering by to the select ID select clause Iterator iter = orderByTokens.iterator(); diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/idclass/WidgetId.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/idclass/WidgetId.java index 58408aad0e..193677a818 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/idclass/WidgetId.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/criteria/idclass/WidgetId.java @@ -49,7 +49,7 @@ public class WidgetId implements Serializable { @Override public String toString( ) { - StringBuffer buf = new StringBuffer( "[id:" ); + StringBuilder buf = new StringBuilder( "[id:" ); buf.append( ( this.getCode( ) == null ) ? "null" : this.getCode( ).toString( ) ); buf.append( ";code:" ); buf.append( ( this.getDivision( ) == null ) ? "null" : this.getDivision( ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/defaultpar/Version.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/defaultpar/Version.java index d4f72d874b..c4d5798ddb 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/defaultpar/Version.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/defaultpar/Version.java @@ -44,6 +44,6 @@ public class Version { } public String toString() { - return new StringBuffer( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString(); + return new StringBuilder( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/defaultpar_1_0/Version1.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/defaultpar_1_0/Version1.java index 83f82f97dd..0626635dda 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/defaultpar_1_0/Version1.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/defaultpar_1_0/Version1.java @@ -44,6 +44,6 @@ public class Version1 { } public String toString() { - return new StringBuffer( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString(); + return new StringBuilder( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString(); } } \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/war/Version.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/war/Version.java index 174196e9bf..96ec605873 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/war/Version.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/pack/war/Version.java @@ -44,6 +44,6 @@ public class Version { } public String toString() { - return new StringBuffer( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString(); + return new StringBuilder( major ).append( DOT ).append( minor ).append( DOT ).append( micro ).toString(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/AlternativeNamingStrategy.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/AlternativeNamingStrategy.java index d8894bb0df..1cd67ed05b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/AlternativeNamingStrategy.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/AlternativeNamingStrategy.java @@ -63,8 +63,7 @@ public class AlternativeNamingStrategy extends EJB3NamingStrategy { return tableName; } else { - //use of a stringbuffer to workaround a JDK bug - return new StringBuffer( ownerEntityTable ).append( "_" ) + return new StringBuilder( ownerEntityTable ).append( "_" ) .append( associatedEntityTable != null ? associatedEntityTable : diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/GetDimensionFunction.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/GetDimensionFunction.java index 0fe5fe1a38..463445c015 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/GetDimensionFunction.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/GetDimensionFunction.java @@ -23,7 +23,7 @@ class GetDimensionFunction extends SDOObjectMethod { } public String render(Type firstArgumentType, final List args, final SessionFactoryImplementor factory) { - final StringBuffer buf = new StringBuffer(); + final StringBuilder buf = new StringBuilder(); if ( args.isEmpty() ) { throw new IllegalArgumentException( "First Argument in arglist must be object to " diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/GetGeometryTypeFunction.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/GetGeometryTypeFunction.java index de18872692..1416c9390b 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/GetGeometryTypeFunction.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/GetGeometryTypeFunction.java @@ -23,7 +23,7 @@ class GetGeometryTypeFunction extends SDOObjectMethod { } public String render(Type firstArgumentType, final List args, final SessionFactoryImplementor factory) { - final StringBuffer buf = new StringBuffer(); + final StringBuilder buf = new StringBuilder(); if ( args.isEmpty() ) { throw new IllegalArgumentException( "First Argument in arglist must be object to which" diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSDOSupport.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSDOSupport.java index 2b066d561b..0026a0f600 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSDOSupport.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSDOSupport.java @@ -106,7 +106,7 @@ class OracleSDOSupport implements SpatialDialect, Serializable, WithCustomJPAFil } public String getOGCSpatialRelateSQL(String arg1, String arg2, int spatialRelation) { - final StringBuffer ogcFunction = new StringBuffer( "MDSYS." ); + final StringBuilder ogcFunction = new StringBuilder( "MDSYS." ); switch ( spatialRelation ) { case SpatialRelation.INTERSECTS: ogcFunction.append( "OGC_INTERSECTS" ); @@ -229,7 +229,7 @@ class OracleSDOSupport implements SpatialDialect, Serializable, WithCustomJPAFil */ @Override public String getSpatialFilterExpression(String columnName) { - final StringBuffer buffer = new StringBuffer( "SDO_FILTER(" ); + final StringBuilder buffer = new StringBuilder( "SDO_FILTER(" ); buffer.append( columnName ); buffer.append( ",?) = 'TRUE' " ); return buffer.toString(); @@ -245,7 +245,7 @@ class OracleSDOSupport implements SpatialDialect, Serializable, WithCustomJPAFil */ @Override public String getSpatialAggregateSQL(String columnName, int aggregation) { - final StringBuffer aggregateFunction = new StringBuffer(); + final StringBuilder aggregateFunction = new StringBuilder(); final SpatialAggregate sa = new SpatialAggregate( aggregation ); if ( sa.getAggregateSyntax() == null ) { diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialFunctions.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialFunctions.java index e25e5e5e87..5649256a1c 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialFunctions.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/OracleSpatialFunctions.java @@ -175,7 +175,7 @@ class OracleSpatialFunctions extends SpatialFunctionsRegistry { static String getOGCSpatialAnalysisSQL(List args, int spatialAnalysisFunction) { boolean[] geomArgs; - final StringBuffer ogcFunction = new StringBuffer( "MDSYS." ); + final StringBuilder ogcFunction = new StringBuilder( "MDSYS." ); boolean isGeomReturn = true; switch ( spatialAnalysisFunction ) { case SpatialAnalysis.BUFFER: @@ -240,7 +240,7 @@ class OracleSpatialFunctions extends SpatialFunctionsRegistry { return ogcFunction.toString(); } - private static StringBuffer wrapInSTGeometry(String geomColumn, StringBuffer toAdd) { + private static StringBuilder wrapInSTGeometry(String geomColumn, StringBuilder toAdd) { return toAdd.append( "MDSYS.ST_GEOMETRY(" ).append( geomColumn ) .append( ")" ); } diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOObjectMethod.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOObjectMethod.java index e245989a17..4b3b84ccef 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOObjectMethod.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOObjectMethod.java @@ -67,7 +67,7 @@ class SDOObjectMethod implements SQLFunction { */ public String render(Type firstArgumentType, List args, SessionFactoryImplementor factory) throws QueryException { - final StringBuffer buf = new StringBuffer(); + final StringBuilder buf = new StringBuilder(); if ( args.isEmpty() ) { throw new QueryException( "First Argument in arglist must be object to which method is applied" diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOObjectProperty.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOObjectProperty.java index a1d045ea97..31dbd6f616 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOObjectProperty.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/SDOObjectProperty.java @@ -68,7 +68,7 @@ class SDOObjectProperty implements SQLFunction { public String render(Type firstArgtype, List args, SessionFactoryImplementor factory) throws QueryException { - final StringBuffer buf = new StringBuffer(); + final StringBuilder buf = new StringBuilder(); if ( args.isEmpty() ) { throw new QueryException( "First Argument in arglist must be object of which property is queried" diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/criterion/OracleSpatialProjection.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/criterion/OracleSpatialProjection.java index fe3073d6d2..7b025f7c81 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/criterion/OracleSpatialProjection.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/oracle/criterion/OracleSpatialProjection.java @@ -49,7 +49,7 @@ public class OracleSpatialProjection extends SimpleProjection { if ( dialect instanceof SpatialDialect ) { final SpatialDialect seDialect = (SpatialDialect) dialect; - return new StringBuffer( + return new StringBuilder( seDialect.getSpatialAggregateSQL( columns[0], this.aggregate ) diff --git a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerMethod.java b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerMethod.java index 504ded5fa4..d831581f30 100644 --- a/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerMethod.java +++ b/hibernate-spatial/src/main/java/org/hibernate/spatial/dialect/sqlserver/SqlServerMethod.java @@ -24,7 +24,7 @@ class SqlServerMethod extends StandardSQLFunction { @Override public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor sessionFactory) { - final StringBuffer buf = new StringBuffer(); + final StringBuilder buf = new StringBuilder(); if ( arguments.size() < 1 ) { buf.append( getName() ).append( "()" ); } From 97ea1d853d3e7c76c3aa6c985b38c1d63cbca437 Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Mon, 7 Sep 2020 18:47:09 -0400 Subject: [PATCH 02/16] HHH-14208 simplify example naming strategy code in user guide --- .../AcmeCorpPhysicalNamingStrategy.java | 79 +++++-------------- 1 file changed, 20 insertions(+), 59 deletions(-) diff --git a/documentation/src/test/java/org/hibernate/userguide/naming/AcmeCorpPhysicalNamingStrategy.java b/documentation/src/test/java/org/hibernate/userguide/naming/AcmeCorpPhysicalNamingStrategy.java index 404f62801e..cbd8707904 100644 --- a/documentation/src/test/java/org/hibernate/userguide/naming/AcmeCorpPhysicalNamingStrategy.java +++ b/documentation/src/test/java/org/hibernate/userguide/naming/AcmeCorpPhysicalNamingStrategy.java @@ -6,14 +6,15 @@ */ package org.hibernate.userguide.naming; -import java.util.LinkedList; +import java.util.Arrays; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.TreeMap; +import java.util.stream.Collectors; import org.hibernate.boot.model.naming.Identifier; -import org.hibernate.boot.model.naming.PhysicalNamingStrategy; +import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl; import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; import org.apache.commons.lang3.StringUtils; @@ -27,40 +28,35 @@ import org.apache.commons.lang3.StringUtils; * Additionally standards call for the replacement of certain words with abbreviations. * * @author Steve Ebersole + * @author Nathan Xu */ -public class AcmeCorpPhysicalNamingStrategy implements PhysicalNamingStrategy { - private static final Map ABBREVIATIONS = buildAbbreviationMap(); +public class AcmeCorpPhysicalNamingStrategy extends PhysicalNamingStrategyStandardImpl { + private static final Map ABBREVIATIONS; - @Override - public Identifier toPhysicalCatalogName(Identifier name, JdbcEnvironment jdbcEnvironment) { - // Acme naming standards do not apply to catalog names - return name; - } - - @Override - public Identifier toPhysicalSchemaName(Identifier name, JdbcEnvironment jdbcEnvironment) { - // Acme naming standards do not apply to schema names - return name; + static { + ABBREVIATIONS = new TreeMap<>( String.CASE_INSENSITIVE_ORDER ); + ABBREVIATIONS.put( "account", "acct" ); + ABBREVIATIONS.put( "number", "num" ); } @Override public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) { final List parts = splitAndReplace( name.getText() ); return jdbcEnvironment.getIdentifierHelper().toIdentifier( - join( parts ), + StringUtils.join( parts, '_' ), name.isQuoted() ); } @Override public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment) { - final LinkedList parts = splitAndReplace( name.getText() ); + final List parts = splitAndReplace( name.getText() ); // Acme Corp says all sequences should end with _seq - if ( !"seq".equalsIgnoreCase( parts.getLast() ) ) { + if ( !"seq".equals( parts.get( parts.size() - 1 ) ) ) { parts.add( "seq" ); } return jdbcEnvironment.getIdentifierHelper().toIdentifier( - join( parts ), + StringUtils.join( parts, '_' ), name.isQuoted() ); } @@ -69,50 +65,15 @@ public class AcmeCorpPhysicalNamingStrategy implements PhysicalNamingStrategy { public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) { final List parts = splitAndReplace( name.getText() ); return jdbcEnvironment.getIdentifierHelper().toIdentifier( - join( parts ), + StringUtils.join( parts, '_' ), name.isQuoted() ); } - private static Map buildAbbreviationMap() { - TreeMap abbreviationMap = new TreeMap<> ( String.CASE_INSENSITIVE_ORDER ); - abbreviationMap.put( "account", "acct" ); - abbreviationMap.put( "number", "num" ); - return abbreviationMap; - } - - private LinkedList splitAndReplace(String name) { - LinkedList result = new LinkedList<>(); - for ( String part : StringUtils.splitByCharacterTypeCamelCase( name ) ) { - if ( part == null || part.trim().isEmpty() ) { - // skip null and space - continue; - } - part = applyAbbreviationReplacement( part ); - result.add( part.toLowerCase( Locale.ROOT ) ); - } - return result; - } - - private String applyAbbreviationReplacement(String word) { - if ( ABBREVIATIONS.containsKey( word ) ) { - return ABBREVIATIONS.get( word ); - } - - return word; - } - - private String join(List parts) { - boolean firstPass = true; - String separator = ""; - StringBuilder joined = new StringBuilder(); - for ( String part : parts ) { - joined.append( separator ).append( part ); - if ( firstPass ) { - firstPass = false; - separator = "_"; - } - } - return joined.toString(); + private List splitAndReplace(String name) { + return Arrays.stream( StringUtils.splitByCharacterTypeCamelCase( name ) ) + .filter( StringUtils::isNotBlank ) + .map( p -> ABBREVIATIONS.getOrDefault( p, p ).toLowerCase( Locale.ROOT ) ) + .collect( Collectors.toList() ); } } From 1cf99c748a19bb23ceba9ff640df742fa29ba620 Mon Sep 17 00:00:00 2001 From: Falko Modler Date: Mon, 24 Aug 2020 17:42:27 +0200 Subject: [PATCH 03/16] HHH-14031 Update h2 to 1.4.197 Notes: - h2 1.4.197+ does not support ns precision by default anymore - h2 DateTimeUtils.resetCalendar() is required for many tests to avoid failures due to h2 internal caching --- gradle/libraries.gradle | 2 +- .../org/hibernate/test/temporal/TimePropertyTest.java | 4 +++- .../hibernate/test/type/AbstractJavaTimeTypeTest.java | 11 +++-------- .../testing/junit4/BaseCoreFunctionalTestCase.java | 8 ++++++++ .../junit4/BaseNonConfigCoreFunctionalTestCase.java | 8 ++++++++ 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/gradle/libraries.gradle b/gradle/libraries.gradle index 88c0b75134..216c9da50b 100644 --- a/gradle/libraries.gradle +++ b/gradle/libraries.gradle @@ -10,7 +10,7 @@ ext { junitVersion = '4.12' - h2Version = '1.4.196' + h2Version = '1.4.197' bytemanVersion = '4.0.13' //Compatible with JDK16 jnpVersion = '5.0.6.CR1' diff --git a/hibernate-core/src/test/java/org/hibernate/test/temporal/TimePropertyTest.java b/hibernate-core/src/test/java/org/hibernate/test/temporal/TimePropertyTest.java index d77d122861..f43541fbc5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/temporal/TimePropertyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/temporal/TimePropertyTest.java @@ -10,7 +10,6 @@ import java.sql.Time; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; -import java.util.Date; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; @@ -41,6 +40,9 @@ public class TimePropertyTest extends BaseCoreFunctionalTestCase { // See javadoc for java.sql.Time: 'The date components should be set to the "zero epoch" value of January 1, 1970 and should not be accessed' // Other dates can potentially lead to errors in JDBC drivers, in particular MySQL ConnectorJ 8.x. calendar.set( 1970, Calendar.JANUARY, 1 ); + // H2Dialect uses TIME (without fractional seconds precision) so H2 would round half up if milliseconds were set + // See also: http://h2database.com/html/datatypes.html#time_type + calendar.set( Calendar.MILLISECOND, 0 ); eOrig.tAsDate = new Time( calendar.getTimeInMillis() ); Session s = openSession(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java index 8baef27657..93933bcaa2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/type/AbstractJavaTimeTypeTest.java @@ -20,16 +20,10 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.H2Dialect; -import org.hibernate.dialect.MariaDB10Dialect; -import org.hibernate.dialect.Oracle8iDialect; -import org.hibernate.dialect.PostgreSQL81Dialect; import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; import org.hibernate.testing.TestForIssue; @@ -304,8 +298,9 @@ abstract class AbstractJavaTimeTypeTest extends BaseCoreFunctionalTestCase } protected final boolean isNanosecondPrecisionSupported() { - // Most databases apparently don't support nanosecond precision correctly - return dialect instanceof H2Dialect; + // This used to return true for H2Dialect, but as of 1.4.197 h2 does not use ns precision by default anymore. + // Bringing back ns precision would require timestamp(9) in the dialect class. + return false; } protected final S add(ZoneId defaultJvmTimeZone, Object ... subClassParameters) { diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java index 8b4526b128..cd92e3e5d9 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java @@ -35,6 +35,7 @@ import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.internal.build.AllowSysOut; +import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.jdbc.AbstractReturningWork; @@ -350,6 +351,11 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase { @After public final void afterTest() throws Exception { + // see https://github.com/hibernate/hibernate-orm/pull/3412#issuecomment-678338398 + if ( getDialect() instanceof H2Dialect ) { + ReflectHelper.getMethod( Class.forName( "org.h2.util.DateTimeUtils" ), "resetCalendar" ).invoke( null ); + } + completeStrayTransaction(); if ( isCleanupTestDataRequired() ) { @@ -425,6 +431,8 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase { } public static class RollbackWork implements Work { + + @Override public void execute(Connection connection) throws SQLException { connection.rollback(); } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java index 7a9640806f..961c008846 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java @@ -40,6 +40,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.internal.build.AllowPrintStacktrace; import org.hibernate.internal.build.AllowSysOut; +import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.jdbc.Work; import org.hibernate.mapping.Collection; @@ -450,6 +451,11 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase { @After public final void afterTest() throws Exception { + // see https://github.com/hibernate/hibernate-orm/pull/3412#issuecomment-678338398 + if ( getDialect() instanceof H2Dialect ) { + ReflectHelper.getMethod( Class.forName( "org.h2.util.DateTimeUtils" ), "resetCalendar" ).invoke( null ); + } + completeStrayTransaction(); if ( isCleanupTestDataRequired() ) { @@ -505,6 +511,8 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase { } public class RollbackWork implements Work { + + @Override public void execute(Connection connection) throws SQLException { connection.rollback(); } From 3846001907fa1286071a69cb465bbff4bf6111b1 Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Fri, 28 Aug 2020 16:42:40 -0400 Subject: [PATCH 04/16] HHH-14206 Auto-apply converter not applied to primitives --- ...icableConverterDescriptorStandardImpl.java | 8 ++- .../converter/AttributeConverterTest.java | 57 +++++++++++++++++-- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/convert/internal/AutoApplicableConverterDescriptorStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/model/convert/internal/AutoApplicableConverterDescriptorStandardImpl.java index 5f04d936ce..0ffefbd73b 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/convert/internal/AutoApplicableConverterDescriptorStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/convert/internal/AutoApplicableConverterDescriptorStandardImpl.java @@ -20,6 +20,7 @@ import org.hibernate.boot.model.convert.spi.AutoApplicableConverterDescriptor; import org.hibernate.boot.model.convert.spi.ConverterDescriptor; import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.cfg.annotations.HCANNHelper; +import org.hibernate.internal.util.type.PrimitiveWrapperHelper; import com.fasterxml.classmate.ResolvedType; import com.fasterxml.classmate.ResolvedTypeWithMembers; @@ -147,7 +148,11 @@ public class AutoApplicableConverterDescriptorStandardImpl implements AutoApplic } private boolean typesMatch(ResolvedType converterDefinedType, ResolvedType checkType) { - if ( !converterDefinedType.getErasedType().isAssignableFrom( checkType.getErasedType() ) ) { + Class erasedCheckType = checkType.getErasedType(); + if ( erasedCheckType.isPrimitive() ) { + erasedCheckType = PrimitiveWrapperHelper.getDescriptorByPrimitiveType( erasedCheckType ).getWrapperClass(); + } + if ( !converterDefinedType.getErasedType().isAssignableFrom( erasedCheckType ) ) { return false; } @@ -180,4 +185,5 @@ public class AutoApplicableConverterDescriptorStandardImpl implements AutoApplic return true; } + } diff --git a/hibernate-core/src/test/java/org/hibernate/test/converter/AttributeConverterTest.java b/hibernate-core/src/test/java/org/hibernate/test/converter/AttributeConverterTest.java index 2741457d13..a8d46871d8 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/converter/AttributeConverterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/converter/AttributeConverterTest.java @@ -29,8 +29,8 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; -import org.hibernate.dialect.HANACloudColumnStoreDialect; import org.hibernate.dialect.Dialect; +import org.hibernate.dialect.HANACloudColumnStoreDialect; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.hql.internal.ast.tree.JavaConstantNode; import org.hibernate.internal.util.ConfigHelper; @@ -42,15 +42,16 @@ import org.hibernate.type.BasicType; import org.hibernate.type.Type; import org.hibernate.type.descriptor.converter.AttributeConverterTypeAdapter; import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor; +import org.hibernate.type.descriptor.java.IntegerTypeDescriptor; import org.hibernate.type.descriptor.java.StringTypeDescriptor; +import org.hibernate.type.descriptor.sql.ClobTypeDescriptor; +import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; +import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.boot.MetadataBuildingContextTestingImpl; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.util.ExceptionUtil; -import org.hibernate.type.descriptor.sql.BlobTypeDescriptor; -import org.hibernate.type.descriptor.sql.ClobTypeDescriptor; -import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; import org.junit.Test; import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping; @@ -278,6 +279,36 @@ public class AttributeConverterTest extends BaseUnitTestCase { } } + @Test + @TestForIssue( jiraKey = "HHH-14206" ) + public void testPrimitiveTypeConverterAutoApplied() { + final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build(); + + try { + MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( ssr ) + .addAnnotatedClass( Tester5.class ) + .getMetadataBuilder() + .applyAttributeConverter( IntegerToVarcharConverter.class, true ) + .build(); + + PersistentClass tester = metadata.getEntityBinding( Tester5.class.getName() ); + Property codeProp = tester.getProperty( "code" ); + SimpleValue nameValue = (SimpleValue) codeProp.getValue(); + Type type = nameValue.getType(); + assertNotNull( type ); + if ( !AttributeConverterTypeAdapter.class.isInstance( type ) ) { + fail( "AttributeConverter not applied to primitive type field: code(int)" ); + } + AttributeConverterTypeAdapter basicType = assertTyping( AttributeConverterTypeAdapter.class, type ); + assertSame( IntegerTypeDescriptor.INSTANCE, basicType.getJavaTypeDescriptor() ); + SqlTypeDescriptor sqlTypeDescriptor = basicType.getSqlTypeDescriptor(); + assertEquals( VarcharTypeDescriptor.INSTANCE.getSqlType(), sqlTypeDescriptor.getSqlType() ); + } + finally { + StandardServiceRegistryBuilder.destroy( ssr ); + } + } + @Test public void testBasicTimestampUsage() { Configuration cfg = new Configuration(); @@ -513,6 +544,24 @@ public class AttributeConverterTest extends BaseUnitTestCase { } } + @Entity(name = "T5") + @SuppressWarnings("UnusedDeclaration") + public static class Tester5 { + @Id + private Long id; + private String name; + private int code; + + public Tester5() { + } + + public Tester5(Long id, String name, int code) { + this.id = id; + this.name = name; + this.code = code; + } + } + // This class is for mimicking an Instant from Java 8, which a converter might convert to a java.sql.Timestamp public static class Instant implements Serializable { private static final long serialVersionUID = 1L; From f203bda5dbab294be4cfd8a1aa8dd64f450eab16 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Wed, 2 Sep 2020 22:18:42 +0200 Subject: [PATCH 05/16] HHH-14204 Schema validator should be more forgiving of column type mismatches --- .../java/org/hibernate/dialect/Dialect.java | 31 +++++++++++++++++++ .../java/org/hibernate/mapping/Table.java | 7 +++-- .../internal/AbstractSchemaValidator.java | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) 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 10ac712992..a85f50b337 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -259,6 +259,37 @@ public abstract class Dialect implements ConversionContext { uniqueDelegate = new DefaultUniqueDelegate( this ); } + /** + * Do the given JDBC type codes, as defined in {@link Types} represent + * essentially the same type in this dialect of SQL? The default + * implementation treats {@link Types#NUMERIC NUMERIC} and + * {@link Types#DECIMAL DECIMAL} as the same type, and + * {@link Types#FLOAT FLOAT}, {@link Types#REAL REAL}, and + * {@link Types#DOUBLE DOUBLE} as essentially the same type, since the + * ANSI SQL specification fails to meaningfully distinguish them. + * + * @param typeCode1 the first JDBC type code + * @param typeCode2 the second JDBC type code + * + * @return {@code true} if the two type codes are equivalent + */ + public boolean equivalentTypes(int typeCode1, int typeCode2) { + return typeCode1==typeCode2 + || isNumericOrDecimal(typeCode1) && isNumericOrDecimal(typeCode2) + || isFloatOrRealOrDouble(typeCode1) && isFloatOrRealOrDouble(typeCode2); + } + + private static boolean isNumericOrDecimal(int typeCode) { + return typeCode == Types.NUMERIC + || typeCode == Types.DECIMAL; + } + + private static boolean isFloatOrRealOrDouble(int typeCode) { + return typeCode == Types.FLOAT + || typeCode == Types.REAL + || typeCode == Types.DOUBLE; + } + /** * Get an instance of the dialect specified by the current System properties. * @deprecated this static method will be removed. 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 19b5ba57a2..50d132d9ea 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java @@ -420,9 +420,10 @@ public class Table implements RelationalModel, Serializable, Exportable { 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(Locale.ROOT) - .startsWith( columnInfo.getTypeName().toLowerCase(Locale.ROOT) ) - || columnInfo.getTypeCode() == col.getSqlTypeCode( mapping ); + final boolean typesMatch = + dialect.equivalentTypes( columnInfo.getTypeCode(), col.getSqlTypeCode( mapping ) ) + || col.getSqlType( dialect, mapping ).toLowerCase(Locale.ROOT) + .startsWith( columnInfo.getTypeName().toLowerCase(Locale.ROOT) ); if ( !typesMatch ) { throw new HibernateException( "Wrong column type in " + diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaValidator.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaValidator.java index c9d0d5bfcf..b8abdec816 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaValidator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaValidator.java @@ -152,7 +152,7 @@ public abstract class AbstractSchemaValidator implements SchemaValidator { Metadata metadata, ExecutionOptions options, Dialect dialect) { - boolean typesMatch = column.getSqlTypeCode( metadata ) == columnInformation.getTypeCode() + boolean typesMatch = dialect.equivalentTypes( column.getSqlTypeCode( metadata ), columnInformation.getTypeCode() ) || column.getSqlType( dialect, metadata ).toLowerCase(Locale.ROOT).startsWith( columnInformation.getTypeName().toLowerCase(Locale.ROOT) ); if ( !typesMatch ) { throw new SchemaManagementException( From f91ed82757ec722072f6fb747c4cb6a6a23a4426 Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Sun, 13 Sep 2020 12:42:16 -0400 Subject: [PATCH 06/16] HHH-14213 fix query numeric literal (integer representation) parsing exception message --- .../internal/ast/util/LiteralProcessor.java | 5 +- ...esentationLiteralParsingExceptionTest.java | 52 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/query/IntegerRepresentationLiteralParsingExceptionTest.java 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 147531dd2c..480a653aba 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 @@ -219,12 +219,14 @@ public class LiteralProcessor implements HqlSqlTokenTypes { } private String determineIntegerRepresentation(String text, int type) { + Class javaTypeClass = Integer.class; try { if ( type == NUM_BIG_INTEGER ) { String literalValue = text; if ( literalValue.endsWith( "bi" ) || literalValue.endsWith( "BI" ) ) { literalValue = literalValue.substring( 0, literalValue.length() - 2 ); } + javaTypeClass = BigInteger.class; return new BigInteger( literalValue ).toString(); } if ( type == NUM_INT ) { @@ -242,10 +244,11 @@ public class LiteralProcessor implements HqlSqlTokenTypes { if ( literalValue.endsWith( "l" ) || literalValue.endsWith( "L" ) ) { literalValue = literalValue.substring( 0, literalValue.length() - 1 ); } + javaTypeClass = Long.class; return Long.valueOf( literalValue ).toString(); } catch (Throwable t) { - throw new HibernateException( "Could not parse literal [" + text + "] as integer", t ); + throw new HibernateException( "Could not parse literal [" + text + "] as " + javaTypeClass.getName(), t ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/query/IntegerRepresentationLiteralParsingExceptionTest.java b/hibernate-core/src/test/java/org/hibernate/query/IntegerRepresentationLiteralParsingExceptionTest.java new file mode 100644 index 0000000000..66b27504df --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/query/IntegerRepresentationLiteralParsingExceptionTest.java @@ -0,0 +1,52 @@ +package org.hibernate.query; + +import javax.persistence.Entity; +import javax.persistence.Id; + +import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; + +import org.hibernate.testing.TestForIssue; +import org.junit.Assert; +import org.junit.Test; + +import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; + +/** + * @author Andrias Sundskar + * @author Nathan Xu + */ +@TestForIssue( jiraKey = "HHH-14213" ) +public class IntegerRepresentationLiteralParsingExceptionTest extends BaseEntityManagerFunctionalTestCase { + + @Override + public Class[] getAnnotatedClasses() { + return new Class[] { ExampleEntity.class }; + } + + @Test + public void testAppropriateExceptionMessageGenerated() { + try { + doInJPA( this::entityManagerFactory, entityManager -> { + // -9223372036854775808 is beyond Long range, so an Exception will be thrown + entityManager.createQuery( "select count(*) from ExampleEntity where counter = -9223372036854775808L" ) + .getSingleResult(); + } ); + Assert.fail( "Exception should be thrown" ); + } + catch (Exception e) { + // without fixing HHH-14213, the following exception would be thrown: + // "Could not parse literal [9223372036854775808L] as integer" + // which is confusing and misleading + Assert.assertTrue( e.getMessage().endsWith( " as java.lang.Long" ) ); + } + } + + @Entity(name = "ExampleEntity") + static class ExampleEntity { + + @Id + int id; + + long counter; + } +} From cf9425924811088ef07a4a9add5da221f86d35f1 Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Mon, 31 Aug 2020 05:58:42 -0400 Subject: [PATCH 07/16] HHH-14148 fix issue mapping order SQL fragment could produce incorrect SQL --- hibernate-core/src/main/antlr/sql-gen.g | 9 ++++-- .../annotations/onetomany/OrderByTest.java | 28 +++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/antlr/sql-gen.g b/hibernate-core/src/main/antlr/sql-gen.g index c8eeda17f6..e2659df245 100644 --- a/hibernate-core/src/main/antlr/sql-gen.g +++ b/hibernate-core/src/main/antlr/sql-gen.g @@ -146,7 +146,7 @@ selectStatement from ( #(WHERE { out(" where "); } whereExpr ) )? ( #(GROUP { out(" group by "); } groupExprs ( #(HAVING { out(" having "); } booleanExpr[false]) )? ) )? - ( #(ORDER { out(" order by "); } orderExprs ) )? + ( #(ORDER { out(" order by "); } orderBySqlFragmentOrExprs ) )? ) ; @@ -191,6 +191,11 @@ whereClauseExpr | booleanExpr[ false ] ; +orderBySqlFragmentOrExprs + : sqlToken // for the purpose of mapping-defined orderBy SQL fragment + | orderExprs + ; + orderExprs { String ordExp = null; String ordDir = null; String ordNul = null; } // TODO: remove goofy space before the comma when we don't have to regression test anymore. // Dialect is provided a hook to render each ORDER BY element, so the expression is being captured instead of @@ -277,7 +282,7 @@ distinctOrAll ; countExpr - // Syntacitic predicate resolves star all by itself, avoiding a conflict with STAR in expr. + // Syntactic predicate resolves star all by itself, avoiding a conflict with STAR in expr. : ROW_STAR { out("*"); } | simpleExpr ; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/OrderByTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/OrderByTest.java index 8b22d32c70..52870917a8 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/OrderByTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/OrderByTest.java @@ -24,15 +24,17 @@ import org.hibernate.Criteria; import org.hibernate.Hibernate; import org.hibernate.NullPrecedence; import org.hibernate.Session; +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.cfg.Configuration; import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.SQLServer2008Dialect; -import org.hibernate.dialect.SQLServer2012Dialect; -import org.hibernate.dialect.SQLServerDialect; import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.graph.RootGraph; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.QueryableCollection; +import org.hibernate.query.Query; import org.hibernate.sql.SimpleSelect; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; @@ -515,6 +517,28 @@ public class OrderByTest extends BaseCoreFunctionalTestCase { s.close(); } + @Test + @TestForIssue( jiraKey = "HHH-14148" ) + @RequiresDialect(value = { H2Dialect.class, MySQLDialect.class, SQLServer2008Dialect.class }, + comment = "By default H2 places NULL values first, so testing 'NULLS LAST' expression. " + + "For MySQL and SQL Server 2008 testing overridden Dialect#renderOrderByElement(String, String, String, NullPrecedence) method. " + + "MySQL and SQL Server 2008 does not support NULLS FIRST / LAST syntax at the moment, so transforming the expression to 'CASE WHEN ...'.") + public void testNullPrecedenceWithOrderBySqlFragment() { + inTransaction( session -> { + final RootGraph graph = session.createEntityGraph( Order.class ); + graph.addAttributeNodes( "itemList" ); + + Query query = session.createQuery( "from Order", Order.class ); + query.applyFetchGraph( graph ); + query.getResultList(); // before HHH-14148 is fixed, incorrect SQL would be generated ending with " nulls last nulls last" + } ); + } + + @Override + protected void configure(Configuration configuration) { + configuration.setProperty( AvailableSettings.DEFAULT_NULL_ORDERING, "last" ); + } + @Override protected Class[] getAnnotatedClasses() { return new Class[] { From 886083ab77f6ac41711c053b5bca097868c9b7c3 Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Wed, 2 Sep 2020 15:06:27 -0400 Subject: [PATCH 08/16] HHH-14201 fix HQL JOIN order issue --- hibernate-core/src/main/antlr/sql-gen.g | 7 +- .../hql/internal/ast/tree/FromClause.java | 30 +++---- .../org/hibernate/query/JoinOrderTest.java | 86 +++++++++++++++++++ 3 files changed, 101 insertions(+), 22 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/query/JoinOrderTest.java diff --git a/hibernate-core/src/main/antlr/sql-gen.g b/hibernate-core/src/main/antlr/sql-gen.g index e2659df245..4f5f57a91e 100644 --- a/hibernate-core/src/main/antlr/sql-gen.g +++ b/hibernate-core/src/main/antlr/sql-gen.g @@ -314,12 +314,13 @@ fromTable // Write the table node (from fragment) and all the join fragments associated with it. : #( a:FROM_FRAGMENT { out(a); } (tableJoin [ a ])* { fromFragmentSeparator(a); } ) | #( b:JOIN_FRAGMENT { out(b); } (tableJoin [ b ])* { fromFragmentSeparator(b); } ) - | #( e:ENTITY_JOIN { out(e); } (tableJoin [ e ])* { fromFragmentSeparator(e); } ) + | #( c:ENTITY_JOIN { out(c); } (tableJoin [ c ])* { fromFragmentSeparator(c); } ) ; tableJoin [ AST parent ] - : #( c:JOIN_FRAGMENT { out(" "); out(c); } (tableJoin [ c ] )* ) - | #( d:FROM_FRAGMENT { nestedFromFragment(d,parent); } (tableJoin [ d ] )* ) + : #( d:JOIN_FRAGMENT { out(" "); out(d); } (tableJoin [ d ] )* ) + | #( e:FROM_FRAGMENT { nestedFromFragment(e,parent); } (tableJoin [ e ] )* ) + | #( f:ENTITY_JOIN { out(" "); out(f); } (tableJoin [ f ] )* ) ; booleanOp[ boolean parens ] diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java index 5d854c6b0f..0288159da8 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java @@ -6,9 +6,9 @@ */ package org.hibernate.hql.internal.ast.tree; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -34,7 +34,7 @@ public class FromClause extends HqlSqlWalkerNode implements HqlSqlTokenTypes, Di public static final int ROOT_LEVEL = 1; private int level = ROOT_LEVEL; - private Set fromElements = new HashSet(); + private Set fromElements = new LinkedHashSet(); private Map fromElementByClassAlias = new HashMap(); private Map fromElementByTableAlias = new HashMap(); private Map fromElementsByPath = new HashMap(); @@ -61,8 +61,6 @@ public class FromClause extends HqlSqlWalkerNode implements HqlSqlTokenTypes, Di */ private List impliedElements = new LinkedList(); - private List entityJoinFromElements; - /** * Adds a new from element to the from node. * @@ -91,25 +89,18 @@ public class FromClause extends HqlSqlWalkerNode implements HqlSqlTokenTypes, Di if ( tableAlias != null ) { fromElementByTableAlias.put( tableAlias, element ); } - - if ( element instanceof EntityJoinFromElement ) { - if ( entityJoinFromElements == null ) { - entityJoinFromElements = new ArrayList(); - } - entityJoinFromElements.add( (EntityJoinFromElement) element ); - } } public void finishInit() { - if ( entityJoinFromElements == null ) { - return; + // Insert EntityJoinFromElements while maintaining their original position during depth-first traversal. + FromElement lastFromElement = null; + for ( FromElement fromElement : fromElements ) { + if ( fromElement instanceof EntityJoinFromElement ) { + assert lastFromElement != null; + ASTUtil.insertChild( lastFromElement, fromElement ); + } + lastFromElement = fromElement; } - - for ( EntityJoinFromElement entityJoinFromElement : entityJoinFromElements ) { - ASTUtil.appendChild( this, entityJoinFromElement ); - } - - entityJoinFromElements.clear(); } void addDuplicateAlias(String alias, FromElement element) { @@ -412,4 +403,5 @@ public class FromClause extends HqlSqlWalkerNode implements HqlSqlTokenTypes, Di public String toString() { return "FromClause{level=" + level + "}"; } + } diff --git a/hibernate-core/src/test/java/org/hibernate/query/JoinOrderTest.java b/hibernate-core/src/test/java/org/hibernate/query/JoinOrderTest.java new file mode 100644 index 0000000000..b655d76379 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/query/JoinOrderTest.java @@ -0,0 +1,86 @@ +package org.hibernate.query; + +import java.util.Map; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.jdbc.SQLStatementInterceptor; +import org.junit.Test; + +import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; +import static org.junit.Assert.assertTrue; + +/** + * @author Christian Beikov + * @author Nathan Xu + */ +@TestForIssue( jiraKey = "HHH-14201" ) +public class JoinOrderTest extends BaseEntityManagerFunctionalTestCase { + + private SQLStatementInterceptor sqlStatementInterceptor; + + @Override + protected void addConfigOptions(Map options) { + sqlStatementInterceptor = new SQLStatementInterceptor( options ); + } + + @Override + public Class[] getAnnotatedClasses() { + return new Class[] { + EntityA.class, + EntityB.class, + EntityC.class + }; + } + + @Test + public void testJoinOrder() { + doInJPA( this::entityManagerFactory, entityManager -> { + + sqlStatementInterceptor.clear(); + + final String hql = + "SELECT 1 " + + "FROM EntityA a " + + "JOIN EntityB b ON b.a = a " + + "JOIN a.c c ON c.b = b"; + entityManager.createQuery( hql ).getResultList(); + + sqlStatementInterceptor.assertExecutedCount( 1 ); + final String sql = sqlStatementInterceptor.getSqlQueries().getFirst(); + + assertTrue( sql.matches( "^.+(?: join EntityB ).+(?: join EntityC ).+$" ) ); + } ); + } + + @Entity(name = "EntityA") + public static class EntityA { + @Id + int id; + + @ManyToOne + EntityC c; + } + + @Entity(name = "EntityB") + public static class EntityB { + @Id + int id; + + @ManyToOne + EntityA a; + } + + @Entity(name = "EntityC") + public static class EntityC { + @Id + int id; + + @ManyToOne + EntityB b; + } +} From 20e5a5659b25b0eaf2bee780ac7e4f61f0f8bc14 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Mon, 14 Sep 2020 12:35:33 +0200 Subject: [PATCH 09/16] HHH-14148 Fix ANTLR grammar non-determinism --- hibernate-core/src/main/antlr/sql-gen.g | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/hibernate-core/src/main/antlr/sql-gen.g b/hibernate-core/src/main/antlr/sql-gen.g index 4f5f57a91e..ab9151d86c 100644 --- a/hibernate-core/src/main/antlr/sql-gen.g +++ b/hibernate-core/src/main/antlr/sql-gen.g @@ -146,7 +146,7 @@ selectStatement from ( #(WHERE { out(" where "); } whereExpr ) )? ( #(GROUP { out(" group by "); } groupExprs ( #(HAVING { out(" having "); } booleanExpr[false]) )? ) )? - ( #(ORDER { out(" order by "); } orderBySqlFragmentOrExprs ) )? + ( #(ORDER { out(" order by "); } orderExprs ) )? ) ; @@ -191,18 +191,15 @@ whereClauseExpr | booleanExpr[ false ] ; -orderBySqlFragmentOrExprs - : sqlToken // for the purpose of mapping-defined orderBy SQL fragment - | orderExprs - ; - orderExprs { String ordExp = null; String ordDir = null; String ordNul = null; } // TODO: remove goofy space before the comma when we don't have to regression test anymore. // Dialect is provided a hook to render each ORDER BY element, so the expression is being captured instead of // printing to the SQL output directly. See Dialect#renderOrderByElement(String, String, String, NullPrecedence). - : { captureExpressionStart(); } ( expr ) { captureExpressionFinish(); ordExp = resetCapture(); } + : { captureExpressionStart(); } ( e:expr ) { captureExpressionFinish(); ordExp = resetCapture(); } (dir:orderDirection { ordDir = #dir.getText(); })? (ordNul=nullOrdering)? - { out( renderOrderByElement( ordExp, ordDir, ordNul ) ); } + // SQL Tokens without a direction and null ordering can be passed through as-is. + // These tokens could be mapping defined order by fragments which are already rendered via the dialect hook + { out( #e.getType() == SQL_TOKEN && ordDir == null && ordNul == null ? ordExp : renderOrderByElement( ordExp, ordDir, ordNul ) ); } ( {out(", "); } orderExprs )? ; From 7ef5336fecd41d47a67cd27d271f0e65a4d70b4d Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Mon, 14 Sep 2020 14:34:33 +0200 Subject: [PATCH 10/16] HHH-14201 Fix test issues of NaturalIdDereferenceTest --- hibernate-core/src/main/antlr/sql-gen.g | 6 +++--- .../hql/internal/ast/tree/FromClause.java | 18 ++++++++++++++---- .../hql/internal/ast/tree/FromElement.java | 3 +++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/hibernate-core/src/main/antlr/sql-gen.g b/hibernate-core/src/main/antlr/sql-gen.g index ab9151d86c..031586a1e0 100644 --- a/hibernate-core/src/main/antlr/sql-gen.g +++ b/hibernate-core/src/main/antlr/sql-gen.g @@ -193,13 +193,13 @@ whereClauseExpr orderExprs { String ordExp = null; String ordDir = null; String ordNul = null; } // TODO: remove goofy space before the comma when we don't have to regression test anymore. - // Dialect is provided a hook to render each ORDER BY element, so the expression is being captured instead of + // Dialect is provided a hook to render each ORDER BY element(except SQL_TOKEN), so the expression is being captured instead of // printing to the SQL output directly. See Dialect#renderOrderByElement(String, String, String, NullPrecedence). : { captureExpressionStart(); } ( e:expr ) { captureExpressionFinish(); ordExp = resetCapture(); } (dir:orderDirection { ordDir = #dir.getText(); })? (ordNul=nullOrdering)? - // SQL Tokens without a direction and null ordering can be passed through as-is. + // SQL Tokens can be passed through as-is. // These tokens could be mapping defined order by fragments which are already rendered via the dialect hook - { out( #e.getType() == SQL_TOKEN && ordDir == null && ordNul == null ? ordExp : renderOrderByElement( ordExp, ordDir, ordNul ) ); } + { out( #e.getType() == SQL_TOKEN ? ordExp : renderOrderByElement( ordExp, ordDir, ordNul ) ); } ( {out(", "); } orderExprs )? ; diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java index 0288159da8..2e03bf1130 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromClause.java @@ -91,13 +91,23 @@ public class FromClause extends HqlSqlWalkerNode implements HqlSqlTokenTypes, Di } } + void moveFromElementToEnd(FromElement element) { + fromElements.remove( element ); + fromElements.add( element ); + } + public void finishInit() { - // Insert EntityJoinFromElements while maintaining their original position during depth-first traversal. + // Insert the from elements into the AST in the same order as they were added to the HQL AST FromElement lastFromElement = null; for ( FromElement fromElement : fromElements ) { - if ( fromElement instanceof EntityJoinFromElement ) { - assert lastFromElement != null; - ASTUtil.insertChild( lastFromElement, fromElement ); + if ( fromElement instanceof ComponentJoin ) { + // Component joins are no "real" joins, so they can't be put into the AST + continue; + } + fromElement.setFirstChild( null ); + fromElement.setNextSibling( null ); + if ( lastFromElement != null ) { + ASTUtil.appendChild( lastFromElement, fromElement ); } lastFromElement = fromElement; } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java index b4cf19dd7b..91237a8955 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java @@ -642,6 +642,9 @@ public class FromElement extends HqlSqlWalkerNode implements DisplayableNode, Pa } public void setWithClauseFragment(AST ast, String withClauseFragment) { + // Normally, the from element is added first, but since the with clause could introduce joins, + // we have to move the from element to the end to retain the proper join order + getFromClause().moveFromElementToEnd( this ); this.withClauseAst = ast; this.withClauseFragment = withClauseFragment; } From f136dabe181dcaf72ce33ac96b4d7c503fe60185 Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Wed, 16 Sep 2020 22:58:50 -0400 Subject: [PATCH 11/16] HHH-14218 fix some typos in code comments --- hibernate-core/src/main/antlr/hql-sql.g | 2 +- hibernate-core/src/main/antlr/hql.g | 6 ++--- hibernate-core/src/main/antlr/sql-gen.g | 2 +- .../hibernate/UnknownProfileException.java | 2 +- .../action/internal/EntityUpdateAction.java | 2 +- .../boot/internal/MetadataBuilderImpl.java | 2 +- .../internal/hbm/ResultSetMappingBinder.java | 2 +- .../BootstrapServiceRegistryBuilder.java | 2 +- .../javassist/MappedSuperclassEnhancer.java | 2 +- .../PersistentAttributesEnhancer.java | 4 ++-- .../spi/interceptor/EnhancementHelper.java | 2 +- .../internal/DomainDataRegionConfigImpl.java | 2 +- .../cache/internal/NaturalIdCacheKey.java | 2 +- .../internal/RegionFactoryInitiator.java | 2 +- .../spi/entry/StandardCacheEntryImpl.java | 2 +- .../org/hibernate/cfg/AnnotationBinder.java | 22 ++++++++--------- .../java/org/hibernate/cfg/BinderHelper.java | 8 +++---- .../cfg/ComponentPropertyHolder.java | 2 +- .../java/org/hibernate/cfg/Ejb3Column.java | 2 +- .../org/hibernate/cfg/Ejb3JoinColumn.java | 2 +- .../org/hibernate/cfg/InheritanceState.java | 2 +- .../org/hibernate/cfg/OneToOneSecondPass.java | 2 +- .../hibernate/cfg/PropertyPreloadedData.java | 2 +- .../cfg/annotations/CollectionBinder.java | 4 ++-- .../hibernate/cfg/annotations/MapBinder.java | 6 ++--- .../cfg/annotations/PropertyBinder.java | 4 ++-- .../cfg/annotations/SimpleValueBinder.java | 4 ++-- .../JPAOverriddenAnnotationReader.java | 6 ++--- .../BeanValidationIntegrator.java | 2 +- .../AbstractPersistentCollection.java | 2 +- .../internal/ThreadLocalSessionContext.java | 6 ++--- .../dialect/AbstractHANADialect.java | 5 ++-- .../dialect/AbstractTransactSQLDialect.java | 2 +- .../org/hibernate/dialect/DB2Dialect.java | 4 ++-- .../org/hibernate/dialect/IngresDialect.java | 2 +- .../hibernate/dialect/InterbaseDialect.java | 2 +- .../hibernate/dialect/SybaseASE15Dialect.java | 2 +- .../AbstractAnsiTrimEmulationFunction.java | 2 +- .../StandardAnsiSqlAggregationFunctions.java | 2 +- .../Chache71IdentityColumnSupport.java | 2 +- .../pagination/CUBRIDLimitHandler.java | 2 +- .../dialect/pagination/FirstLimitHandler.java | 2 +- .../pagination/LegacyFirstLimitHandler.java | 2 +- .../dialect/pagination/NoopLimitHandler.java | 2 +- .../SQL2008StandardLimitHandler.java | 2 +- .../pagination/SQLServer2005LimitHandler.java | 4 ++-- .../engine/internal/Collections.java | 2 +- .../engine/internal/ForeignKeys.java | 2 +- .../engine/internal/Nullability.java | 6 ++--- .../internal/StatefulPersistenceContext.java | 10 ++++---- .../DefaultFlushEntityEventListener.java | 4 ++-- .../internal/DefaultMergeEventListener.java | 2 +- .../DefaultReplicateEventListener.java | 2 +- .../DirtyCollectionSearchVisitor.java | 4 ++-- .../event/internal/OnLockVisitor.java | 8 +++---- .../event/internal/ProxyVisitor.java | 2 +- .../hibernate/hql/internal/ast/HqlLexer.java | 4 ++-- .../hql/internal/ast/HqlSqlWalker.java | 6 ++--- .../hql/internal/ast/QueryTranslatorImpl.java | 4 ++-- .../hql/internal/ast/SqlGenerator.java | 4 ++-- .../ast/tree/AbstractNullnessCheckNode.java | 4 ++-- .../tree/BinaryArithmeticOperatorNode.java | 2 +- .../ast/tree/BinaryLogicOperatorNode.java | 2 +- .../internal/ast/tree/CollectionSizeNode.java | 2 +- .../hql/internal/ast/tree/ComponentJoin.java | 2 +- .../hql/internal/ast/tree/DotNode.java | 4 ++-- .../ast/tree/EntityJoinFromElement.java | 2 +- .../hql/internal/ast/tree/FromElement.java | 4 ++-- .../internal/ast/tree/FromElementType.java | 4 ++-- .../hql/internal/ast/tree/IdentNode.java | 4 ++-- .../hql/internal/ast/tree/IntoClause.java | 4 ++-- .../ast/tree/MapKeyEntityFromElement.java | 2 +- .../hql/internal/ast/tree/SelectClause.java | 6 ++--- .../hql/internal/ast/util/ColumnHelper.java | 2 +- .../hql/internal/ast/util/JoinProcessor.java | 2 +- .../ast/util/SessionFactoryHelper.java | 2 +- .../hql/internal/classic/FromParser.java | 6 ++--- .../classic/PathExpressionParser.java | 4 ++-- .../internal/classic/QueryTranslatorImpl.java | 2 +- .../hibernate/id/AbstractUUIDGenerator.java | 2 +- .../id/MultipleHiLoPerTableGenerator.java | 2 +- .../hibernate/id/enhanced/HiLoOptimizer.java | 2 +- .../hibernate/id/enhanced/NoopOptimizer.java | 2 +- .../id/enhanced/PooledOptimizer.java | 2 +- .../hibernate/id/enhanced/TableGenerator.java | 2 +- .../AbstractSharedSessionContract.java | 8 +++---- .../internal/SessionFactoryImpl.java | 10 ++++---- .../org/hibernate/internal/SessionImpl.java | 14 +++++------ .../hibernate/internal/util/StringHelper.java | 8 +++---- .../util/type/PrimitiveWrapperHelper.java | 2 +- .../internal/util/xml/ErrorLogger.java | 2 +- .../EntityManagerFactoryBuilderImpl.java | 4 ++-- .../EnhancingClassTransformerImpl.java | 2 +- .../jpa/internal/util/XmlHelper.java | 2 +- .../java/org/hibernate/loader/Loader.java | 2 +- .../loader/criteria/CriteriaLoader.java | 2 +- .../criteria/CriteriaQueryTranslator.java | 4 ++-- .../hibernate/loader/custom/CustomLoader.java | 2 +- .../loader/custom/sql/SQLQueryParser.java | 10 ++++---- .../custom/sql/SQLQueryReturnProcessor.java | 2 +- .../LoadQueryJoinAndFetchProcessor.java | 2 +- .../CollectionReferenceInitializerImpl.java | 2 +- .../org/hibernate/mapping/Collection.java | 4 ++-- .../java/org/hibernate/mapping/Column.java | 6 ++--- .../org/hibernate/mapping/ForeignKey.java | 2 +- .../hibernate/mapping/MappedSuperclass.java | 4 ++-- .../java/org/hibernate/mapping/OneToMany.java | 2 +- .../hibernate/mapping/PersistentClass.java | 2 +- .../java/org/hibernate/mapping/Property.java | 2 +- .../main/java/org/hibernate/mapping/Set.java | 2 +- .../org/hibernate/mapping/SimpleValue.java | 4 ++-- .../metamodel/internal/AttributeFactory.java | 4 ++-- .../metamodel/internal/MetadataContext.java | 8 +++---- .../internal/PluralAttributeBuilder.java | 2 +- .../entity/AbstractEntityPersister.java | 24 +++++++++---------- .../entity/AbstractPropertyMapping.java | 6 ++--- .../entity/UnionSubclassEntityPersister.java | 4 ++-- ...ompositionSingularSubAttributesHelper.java | 2 +- .../org/hibernate/pretty/MessageHelper.java | 2 +- .../access/spi/EnhancedSetterImpl.java | 2 +- .../proxy/AbstractLazyInitializer.java | 2 +- .../criteria/internal/CriteriaQueryImpl.java | 2 +- .../internal/CriteriaSubqueryImpl.java | 2 +- .../expression/EntityTypeExpression.java | 2 +- .../internal/path/PluralAttributePath.java | 6 ++--- .../internal/path/SingularAttributePath.java | 2 +- .../internal/predicate/InPredicate.java | 2 +- .../query/internal/AbstractProducedQuery.java | 2 +- .../ResourceRegistryStandardImpl.java | 2 +- .../org/hibernate/sql/ForUpdateFragment.java | 2 +- .../main/java/org/hibernate/sql/Template.java | 2 +- .../spi/SchemaManagementToolCoordinator.java | 2 +- .../transform/CacheableResultTransformer.java | 2 +- .../PassThroughResultTransformer.java | 2 +- .../org/hibernate/transform/Transformers.java | 2 +- .../tuple/entity/AbstractEntityTuplizer.java | 6 ++--- .../BytecodeEnhancementMetadataPojoImpl.java | 2 +- .../tuple/entity/PojoEntityTuplizer.java | 2 +- .../org/hibernate/type/CollectionType.java | 2 +- .../org/hibernate/type/ComponentType.java | 8 +++---- .../hibernate/type/CompositeCustomType.java | 4 ++-- .../java/org/hibernate/type/EntityType.java | 2 +- .../org/hibernate/type/ManyToOneType.java | 2 +- .../descriptor/java/ArrayMutabilityPlan.java | 2 +- 144 files changed, 252 insertions(+), 253 deletions(-) diff --git a/hibernate-core/src/main/antlr/hql-sql.g b/hibernate-core/src/main/antlr/hql-sql.g index 17a9d8ece3..baa5e1de05 100644 --- a/hibernate-core/src/main/antlr/hql-sql.g +++ b/hibernate-core/src/main/antlr/hql-sql.g @@ -470,7 +470,7 @@ aggregateExpr // Establishes the list of aliases being used by this query. fromClause { // NOTE: This references the INPUT AST! (see http://www.antlr.org/doc/trees.html#Action%20Translation) - // the ouput AST (#fromClause) has not been built yet. + // the output AST (#fromClause) has not been built yet. prepareFromClauseInputTree(#fromClause_in); } : #(f:FROM { pushFromClause(#fromClause,f); handleClauseStart( FROM ); } fromElementList ) { diff --git a/hibernate-core/src/main/antlr/hql.g b/hibernate-core/src/main/antlr/hql.g index 31d75fe683..321dda67a8 100644 --- a/hibernate-core/src/main/antlr/hql.g +++ b/hibernate-core/src/main/antlr/hql.g @@ -162,7 +162,7 @@ tokens } /** - * This method is overriden in the sub class in order to provide the + * This method is overridden in the sub class in order to provide the * 'keyword as identifier' hack. * @param token The token to retry as an identifier. * @param ex The exception to throw if it cannot be retried as an identifier. @@ -547,7 +547,7 @@ aliasedExpression // // Note that the above precedence levels map to the rules below... // Once you have a precedence chart, writing the appropriate rules as below -// is usually very straightfoward +// is usually very straightforward logicalExpression : expression @@ -1032,7 +1032,7 @@ NUM_INT ( // hex // the 'e'|'E' and float suffix stuff look // like hex digits, hence the (...)+ doesn't - // know when to stop: ambig. ANTLR resolves + // know when to stop: ambiguous. ANTLR resolves // it correctly by matching immediately. It // is therefore ok to hush warning. options { warnWhenFollowAmbig=false; } diff --git a/hibernate-core/src/main/antlr/sql-gen.g b/hibernate-core/src/main/antlr/sql-gen.g index 031586a1e0..99b413de54 100644 --- a/hibernate-core/src/main/antlr/sql-gen.g +++ b/hibernate-core/src/main/antlr/sql-gen.g @@ -177,7 +177,7 @@ insertStatement ; setClause - // Simply re-use comparisionExpr, because it already correctly defines the EQ rule the + // Simply re-use comparisonExpr, because it already correctly defines the EQ rule the // way it is needed here; not the most aptly named, but ah : #( SET { out(" set "); } comparisonExpr[false] ( { out(", "); } comparisonExpr[false] )* ) ; diff --git a/hibernate-core/src/main/java/org/hibernate/UnknownProfileException.java b/hibernate-core/src/main/java/org/hibernate/UnknownProfileException.java index 67ce26ca29..22967bad3b 100644 --- a/hibernate-core/src/main/java/org/hibernate/UnknownProfileException.java +++ b/hibernate-core/src/main/java/org/hibernate/UnknownProfileException.java @@ -20,7 +20,7 @@ public class UnknownProfileException extends HibernateException { * @param name The profile name that was unknown. */ public UnknownProfileException(String name) { - super( "Unknow fetch profile [" + name + "]" ); + super( "Unknown fetch profile [" + name + "]" ); this.name = name; } diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java index ea46dd973d..2560cdb966 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java @@ -228,7 +228,7 @@ public class EntityUpdateAction extends EntityAction { session ); if ( persister.hasUpdateGeneratedProperties() ) { - // this entity defines proeprty generation, so process those generated + // this entity defines property generation, so process those generated // values... persister.processUpdateGeneratedProperties( id, instance, state, session ); if ( persister.isVersionPropertyGenerated() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java index f0e281d5b2..ea9edffb91 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java @@ -121,7 +121,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont this.sources = sources; this.options = new MetadataBuildingOptionsImpl( serviceRegistry ); this.bootstrapContext = new BootstrapContextImpl( serviceRegistry, options ); - //this is needed only fro implementig deprecated method + //this is needed only for implementing deprecated method options.setBootstrapContext( bootstrapContext ); for ( MetadataSourcesContributor contributor : diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ResultSetMappingBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ResultSetMappingBinder.java index eb88399059..7ea5f74ff3 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ResultSetMappingBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ResultSetMappingBinder.java @@ -164,7 +164,7 @@ public abstract class ResultSetMappingBinder { int queryReturnPosition) { String alias = rtnSource.getAlias(); if ( StringHelper.isEmpty( alias ) ) { - // hack-around as sqlquery impl depend on having a key. + // hack-around as sqlquery impl depends on having a key. alias = "alias_" + queryReturnPosition; } final String entityName = context.determineEntityName( diff --git a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java index fc27ce7ee3..a9710133b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/registry/BootstrapServiceRegistryBuilder.java @@ -208,7 +208,7 @@ public class BootstrapServiceRegistryBuilder { final ClassLoaderService classLoaderService; if ( providedClassLoaderService == null ) { // Use a set. As an example, in JPA, OsgiClassLoader may be in both - // the providedClassLoaders and the overridenClassLoader. + // the providedClassLoaders and the overriddenClassLoader. final Set classLoaders = new HashSet(); if ( providedClassLoaders != null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/javassist/MappedSuperclassEnhancer.java b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/javassist/MappedSuperclassEnhancer.java index fd77951792..4f0a780206 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/javassist/MappedSuperclassEnhancer.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/javassist/MappedSuperclassEnhancer.java @@ -32,7 +32,7 @@ public class MappedSuperclassEnhancer extends PersistentAttributesEnhancer { super.enhance( managedCtClass ); } - // Generate 'template' methods for each attribute. This will be overriden by the actual entities + // Generate 'template' methods for each attribute. This will be overridden by the actual entities @Override protected CtMethod generateFieldReader( diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/javassist/PersistentAttributesEnhancer.java b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/javassist/PersistentAttributesEnhancer.java index 17e70f2416..c28aec4936 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/javassist/PersistentAttributesEnhancer.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/javassist/PersistentAttributesEnhancer.java @@ -400,7 +400,7 @@ public class PersistentAttributesEnhancer extends EnhancerImpl { String toArrayMethod = isMap ? "values().toArray()" : "toArray()"; // only remove elements not in the new collection or else we would loose those elements - // don't use iterator to avoid ConcurrentModException + // don't use iterator to avoid ConcurrentModificationException fieldWriter.insertBefore( String.format( " if (this.%3$s != null && %1$s) {%n" + @@ -561,7 +561,7 @@ public class PersistentAttributesEnhancer extends EnhancerImpl { managedCtClass.addInterface( compositeOwnerCtClass ); if ( enhancementContext.isCompositeClass( managedCtClass ) ) { - // if a composite have a embedded field we need to implement the TRACKER_CHANGER_NAME method as well + // if a composite has an embedded field we need to implement the TRACKER_CHANGER_NAME method as well MethodWriter.write( managedCtClass, "public void %1$s(String name) {%n" + diff --git a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/EnhancementHelper.java b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/EnhancementHelper.java index 7c509cfe32..89ad60a17f 100644 --- a/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/EnhancementHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/EnhancementHelper.java @@ -129,7 +129,7 @@ public class EnhancementHelper { finally { if ( isTempSession ) { try { - // Commit the JDBC transaction is we started one. + // Commit the JDBC transaction if we started one. if ( !isJta ) { BytecodeLogger.LOGGER.debug( "Enhancement interception Helper#performWork committing transaction on temporary Session" ); session.getTransaction().commit(); diff --git a/hibernate-core/src/main/java/org/hibernate/cache/cfg/internal/DomainDataRegionConfigImpl.java b/hibernate-core/src/main/java/org/hibernate/cache/cfg/internal/DomainDataRegionConfigImpl.java index 36cef8d90a..1020c6c63f 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/cfg/internal/DomainDataRegionConfigImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/cfg/internal/DomainDataRegionConfigImpl.java @@ -117,7 +117,7 @@ public class DomainDataRegionConfigImpl implements DomainDataRegionConfig { } - // todo (6.0) : `EntityPersister` and `CollectionPersister` references here should be replaces with `EntityHierarchy` and `PersistentCollectionDescriptor` + // todo (6.0) : `EntityPersister` and `CollectionPersister` references here should be replaced with `EntityHierarchy` and `PersistentCollectionDescriptor` // // todo : although ^^, couldn't this just be the boot-time model? Is there a specific need for it to be the run-time model? // that would alleviate the difference between 5.3 and 6.0 from the SPI POV diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/NaturalIdCacheKey.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/NaturalIdCacheKey.java index e6b89f82ea..01d6e80547 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/NaturalIdCacheKey.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/NaturalIdCacheKey.java @@ -86,7 +86,7 @@ public class NaturalIdCacheKey implements Serializable { @Override public String initialize() { //Complex toString is needed as naturalIds for entities are not simply based on a single value like primary keys - //the only same way to differentiate the keys is to included the disassembled values in the string. + //the only same way to differentiate the keys is to include the disassembled values in the string. final StringBuilder toStringBuilder = new StringBuilder().append( entityName ).append( "##NaturalId[" ); for ( int i = 0; i < naturalIdValues.length; i++ ) { diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java index d2261b7330..ef712e5dcc 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/RegionFactoryInitiator.java @@ -83,7 +83,7 @@ public class RegionFactoryInitiator implements StandardServiceInitiator> implementors = selector.getRegisteredStrategyImplementors( RegionFactory.class ); if ( setting == null && implementors.size() != 1 ) { - // if either are explicitly defined as TRUE we need a RegionFactory + // if either is explicitly defined as TRUE we need a RegionFactory if ( ( useSecondLevelCache != null && useSecondLevelCache == TRUE ) || ( useQueryCache != null && useQueryCache == TRUE ) ) { throw new CacheException( "Caching was explicitly requested, but no RegionFactory was defined and there is not a single registered RegionFactory" ); diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/entry/StandardCacheEntryImpl.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/entry/StandardCacheEntryImpl.java index 2d88392db5..d724b21fa0 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/entry/StandardCacheEntryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/entry/StandardCacheEntryImpl.java @@ -77,7 +77,7 @@ public class StandardCacheEntryImpl implements CacheEntry { @Override public Serializable[] getDisassembledState() { // todo: this was added to support initializing an entity's EntityEntry snapshot during reattach; - // this should be refactored to instead expose a method to assemble a EntityEntry based on this + // this should be refactored to instead expose a method to assemble an EntityEntry based on this // state for return. return disassembledState; } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java index 9ec2044926..2336265597 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java @@ -537,7 +537,7 @@ public final class AnnotationBinder { LOG.unsupportedMappedSuperclassWithEntityInheritance( clazzToProcess.getName() ); } - //TODO: be more strict with secondarytable allowance (not for ids, not for secondary table join columns etc) + //TODO: be more strict with secondary table allowance (not for ids, not for secondary table join columns etc) InheritanceState inheritanceState = inheritanceStatePerClass.get( clazzToProcess ); AnnotatedClassType classType = context.getMetadataCollector().getClassType( clazzToProcess ); @@ -1032,7 +1032,7 @@ public final class AnnotationBinder { ); AccessType propertyAccessor = entityBinder.getPropertyAccessor( compositeClass ); //In JPA 2, there is a shortcut if the IdClass is the Pk of the associated class pointed to by the id - //it ought to be treated as an embedded and not a real IdClass (at least in the Hibernate's internal way + //it ought to be treated as an embedded and not a real IdClass (at least in the Hibernate's internal way) final boolean isFakeIdClass = isIdClassPkOfTheAssociatedEntity( elementsToProcess, compositeClass, @@ -1589,7 +1589,7 @@ public final class AnnotationBinder { } } if ( isRequiredAnnotationPresent ) { - //create a PropertyData fpr the specJ property holding the mapping + //create a PropertyData for the specJ property holding the mapping PropertyData specJPropertyData = new PropertyInferredData( declaringClass, //same dec @@ -2032,7 +2032,7 @@ public final class AnnotationBinder { } { Column[] keyColumns = null; - //JPA 2 has priority and has different default column values, differenciate legacy from JPA 2 + //JPA 2 has priority and has different default column values, differentiate legacy from JPA 2 Boolean isJPA2 = null; if ( property.isAnnotationPresent( MapKeyColumn.class ) ) { isJPA2 = Boolean.TRUE; @@ -2063,7 +2063,7 @@ public final class AnnotationBinder { } { JoinColumn[] joinKeyColumns = null; - //JPA 2 has priority and has different default column values, differenciate legacy from JPA 2 + //JPA 2 has priority and has different default column values, differentiate legacy from JPA 2 Boolean isJPA2 = null; if ( property.isAnnotationPresent( MapKeyJoinColumns.class ) ) { isJPA2 = Boolean.TRUE; @@ -2565,7 +2565,7 @@ public final class AnnotationBinder { } associationTableBinder.setUniqueConstraints( uniqueConstraints ); associationTableBinder.setJpaIndex( jpaIndexes ); - //set check constaint in the second pass + //set check constraint in the second pass annJoins = joins.length == 0 ? null : joins; annInverseJoins = inverseJoins == null || inverseJoins.length == 0 ? null : inverseJoins; } @@ -2603,7 +2603,7 @@ public final class AnnotationBinder { boolean isIdentifierMapper, MetadataBuildingContext buildingContext, boolean isComponentEmbedded, - boolean isId, //is a identifier + boolean isId, //is an identifier Map inheritanceStatePerClass, String referencedEntityName, //is a component who is overridden by a @MapsId Ejb3JoinColumn[] columns) { @@ -2750,7 +2750,7 @@ public final class AnnotationBinder { //add elements of the embeddable superclass XClass superClass = xClassProcessed.getSuperclass(); while ( superClass != null && superClass.isAnnotationPresent( MappedSuperclass.class ) ) { - //FIXME: proper support of typevariables incl var resolved at upper levels + //FIXME: proper support of type variables incl var resolved at upper levels propContainer = new PropertyContainer( superClass, xClassProcessed, propertyAccessor ); addElementsOfClass( classElements, propContainer, buildingContext ); superClass = superClass.getSuperclass(); @@ -3061,7 +3061,7 @@ public final class AnnotationBinder { final JoinColumn joinColumn = property.getAnnotation( JoinColumn.class ); final JoinColumns joinColumns = property.getAnnotation( JoinColumns.class ); - //Make sure that JPA1 key-many-to-one columns are read only tooj + //Make sure that JPA1 key-many-to-one columns are read only too boolean hasSpecjManyToOne=false; if ( context.getBuildingOptions().isSpecjProprietarySyntaxEnabled() ) { String columnName = ""; @@ -3213,7 +3213,7 @@ public final class AnnotationBinder { KeyValue identifier = propertyHolder.getIdentifier(); if ( identifier == null ) { //this is a @OneToOne in an @EmbeddedId (the persistentClass.identifier is not set yet, it's being built) - //by definition the PK cannot refers to itself so it cannot map to itself + //by definition the PK cannot refer to itself so it cannot map to itself mapToPK = false; } else { @@ -3550,7 +3550,7 @@ public final class AnnotationBinder { InheritanceState state = new InheritanceState( clazz, inheritanceStatePerClass, buildingContext ); if ( superclassState != null ) { //the classes are ordered thus preventing an NPE - //FIXME if an entity has subclasses annotated @MappedSperclass wo sub @Entity this is wrong + //FIXME if an entity has subclasses annotated @MappedSuperclass wo sub @Entity this is wrong superclassState.setHasSiblings( true ); InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( clazz, inheritanceStatePerClass diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java b/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java index 3e7ea54c68..78d04445be 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java @@ -311,7 +311,7 @@ public class BinderHelper { columnsList.append( ") " ); if ( associatedEntity != null ) { - //overidden destination + //overridden destination columnsList.append( "of " ) .append( associatedEntity.getEntityName() ) .append( "." ) @@ -438,7 +438,7 @@ public class BinderHelper { || "embedded".equals( property.getPropertyAccessorName() ) ) { return; } -// FIXME cannot use subproperties becasue the caller needs top level properties +// FIXME cannot use subproperties because the caller needs top level properties // if ( property.isComposite() ) { // Iterator subProperties = ( (Component) property.getValue() ).getPropertyIterator(); // while ( subProperties.hasNext() ) { @@ -459,7 +459,7 @@ public class BinderHelper { } /** - * Retrieve the property by path in a recursive way, including IndetifierProperty in the loop + * Retrieve the property by path in a recursive way, including IdentifierProperty in the loop * If propertyName is null or empty, the IdentifierProperty is returned */ public static Property findPropertyByName(PersistentClass associatedClass, String propertyName) { @@ -685,7 +685,7 @@ public class BinderHelper { if ( gen == null ) { throw new AnnotationException( "Unknown named generator (@GeneratedValue#generatorName): " + generatorName ); } - //This is quite vague in the spec but a generator could override the generate choice + //This is quite vague in the spec but a generator could override the generator choice String identifierGeneratorStrategy = gen.getStrategy(); //yuk! this is a hack not to override 'AUTO' even if generator is set final boolean avoidOverriding = diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ComponentPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/cfg/ComponentPropertyHolder.java index 4a5d78296f..3626566180 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/ComponentPropertyHolder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/ComponentPropertyHolder.java @@ -58,7 +58,7 @@ import org.hibernate.mapping.Table; * @author Emmanuel Bernard */ public class ComponentPropertyHolder extends AbstractPropertyHolder { - //TODO introduce a overrideTable() method for columns held by sec table rather than the hack + //TODO introduce an overrideTable() method for columns held by sec table rather than the hack // joinsPerRealTableName in ClassPropertyHolder private Component component; private boolean isOrWithinEmbeddedId; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java index 7b86d9308b..90f6916920 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java @@ -632,7 +632,7 @@ public class Ejb3Column { } } - //must only be called after all setters are defined and before bind + //must only be called after all setters are defined and before binding private void extractDataFromPropertyData(PropertyData inferredData) { if ( inferredData != null ) { XProperty property = inferredData.getProperty(); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java index 5e1f19e871..9dc1c1d84e 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3JoinColumn.java @@ -419,7 +419,7 @@ public class Ejb3JoinColumn extends Ejb3Column { PersistentClass persistentClass, Map joins, Map inheritanceStatePerClass) { - // TODO shouldn't we deduce the classname from the persistentclasS? + // TODO shouldn't we deduce the classname from the persistentClass? this.propertyHolder = PropertyHolderBuilder.buildPropertyHolder( persistentClass, joins, diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/InheritanceState.java b/hibernate-core/src/main/java/org/hibernate/cfg/InheritanceState.java index 3a49dd778e..029862bb97 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/InheritanceState.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/InheritanceState.java @@ -302,7 +302,7 @@ public class InheritanceState { org.hibernate.mapping.MappedSuperclass parentSuperclass = mappedSuperclass; final Class type = buildingContext.getBootstrapContext().getReflectionManager() .toClass( classesToProcessForMappedSuperclass.get( index ) ); - //add MAppedSuperclass if not already there + //add MappedSuperclass if not already there mappedSuperclass = buildingContext.getMetadataCollector().getMappedSuperclass( type ); if ( mappedSuperclass == null ) { mappedSuperclass = new org.hibernate.mapping.MappedSuperclass( parentSuperclass, superEntity ); diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java b/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java index e52bc4fc2f..5924453c99 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java @@ -49,7 +49,7 @@ public class OneToOneSecondPass implements SecondPass { private String cascadeStrategy; private Ejb3JoinColumn[] joinColumns; - //that suck, we should read that from the property mainly + //that sucks, we should read that from the property mainly public OneToOneSecondPass( String mappedBy, String ownerEntity, diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java b/hibernate-core/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java index e83e5927c2..a4f2ab6902 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java @@ -51,7 +51,7 @@ public class PropertyPreloadedData implements PropertyData { } public XClass getDeclaringClass() { - //Preloaded properties are artificial wrapper for colleciton element accesses + //Preloaded properties are artificial wrapper for collection element accesses //and idClass creation, ignore. return null; } 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 ff48ca5a90..c577158085 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 @@ -554,11 +554,11 @@ public abstract class CollectionBinder { collection.setInverse( isMappedBy ); - //many to many may need some second pass informations + //many to many may need some second pass information if ( !oneToMany && isMappedBy ) { metadataCollector.addMappedBy( getCollectionType().getName(), mappedBy, propertyName ); } - //TODO reducce tableBinder != null and oneToMany + //TODO reduce tableBinder != null and oneToMany XClass collectionType = getCollectionType(); if ( inheritanceStatePerClass == null) throw new AssertionFailure( "inheritanceStatePerClass not set" ); SecondPass sp = getSecondPass( diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java index 32d35bf9e9..e4c16b9a37 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java @@ -185,7 +185,7 @@ public class MapBinder extends CollectionBinder { } else { //this is a true Map mapping - //TODO ugly copy/pastle from CollectionBinder.bindManyToManySecondPass + //TODO ugly copy/paste from CollectionBinder.bindManyToManySecondPass String mapKeyType; Class target = void.class; /* @@ -322,7 +322,7 @@ public class MapBinder extends CollectionBinder { column.setTable( mapValue.getCollectionTable() ); } elementBinder.setColumns( elementColumns ); - //do not call setType as it extract the type from @Type + //do not call setType as it extracts the type from @Type //the algorithm generally does not apply for map key anyway elementBinder.setKey(true); elementBinder.setType( @@ -338,7 +338,7 @@ public class MapBinder extends CollectionBinder { } //FIXME pass the Index Entity JoinColumns if ( !collection.isOneToMany() ) { - //index column shoud not be null + //index column should not be null for (Ejb3JoinColumn col : mapKeyManyToManyColumns) { col.forceNotNull(); } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java index 83c3f0c34a..a039776e89 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java @@ -212,8 +212,8 @@ public class PropertyBinder { private Property bind(Property prop) { if (isId) { final RootClass rootClass = ( RootClass ) holder.getPersistentClass(); - //if an xToMany, it as to be wrapped today. - //FIXME this pose a problem as the PK is the class instead of the associated class which is not really compliant with the spec + //if an xToMany, it has to be wrapped today. + //FIXME this poses a problem as the PK is the class instead of the associated class which is not really compliant with the spec if ( isXToMany || entityBinder.wrapIdsInEmbeddedComponents() ) { Component identifier = (Component) rootClass.getIdentifier(); if (identifier == null) { diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java index 2f55aec0ad..6808459c11 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SimpleValueBinder.java @@ -384,7 +384,7 @@ public class SimpleValueBinder { this.explicitType = explicitType; } - //FIXME raise an assertion failure if setResolvedTypeMapping(String) and setResolvedTypeMapping(Type) are use at the same time + //FIXME raise an assertion failure if setResolvedTypeMapping(String) and setResolvedTypeMapping(Type) are used at the same time public void setExplicitType(Type typeAnn) { if ( typeAnn != null ) { @@ -500,7 +500,7 @@ public class SimpleValueBinder { simpleValue.setTypeParameters( typeDef.getParametersAsProperties() ); } if ( typeParameters != null && typeParameters.size() != 0 ) { - //explicit type params takes precedence over type def params + //explicit type params take precedence over type def params simpleValue.setTypeParameters( typeParameters ); } simpleValue.setTypeName( type ); 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 78ba00db08..b40d2e531c 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 @@ -1377,7 +1377,7 @@ public class JPAOverriddenAnnotationReader implements AnnotationReader { } } if ( elementsForProperty.size() == 0 && defaults.canUseJavaAnnotations() ) { - //we have nothing, so Java annotations might occurs + //we have nothing, so Java annotations might occur Annotation annotation = getPhysicalAnnotation( Version.class ); if ( annotation != null ) { annotationList.add( annotation ); @@ -2614,7 +2614,7 @@ public class JPAOverriddenAnnotationReader implements AnnotationReader { } else { throw new AnnotationException( - "Unknown DiscrimiatorType in XML: " + value + " (" + SCHEMA_VALIDATION + ")" + "Unknown DiscriminatorType in XML: " + value + " (" + SCHEMA_VALIDATION + ")" ); } } @@ -2869,7 +2869,7 @@ public class JPAOverriddenAnnotationReader implements AnnotationReader { secondaryTables.add( AnnotationFactory.create( annotation ) ); } /* - * You can't have both secondary table in XML and Java, + * You can't have both secondary tables in XML and Java, * since there would be no way to "remove" a secondary table */ if ( secondaryTables.size() == 0 && defaults.canUseJavaAnnotations() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java index e4a8a2f4a3..f2524f7144 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java @@ -146,7 +146,7 @@ public class BeanValidationIntegrator implements Integrator { } else { // otherwise check the validation modes - // todo : in many ways this duplicates thew checks done on the TypeSafeActivator when a ValidatorFactory could not be obtained + // todo : in many ways this duplicates the checks done on the TypeSafeActivator when a ValidatorFactory could not be obtained validateMissingBeanValidationApi( modes ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java index 56bb0b6c5b..047f414d44 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java @@ -752,7 +752,7 @@ public abstract class AbstractPersistentCollection implements Serializable, Pers // AST in ORM 5+, handling this type of condition is either extremely difficult or impossible. Forcing // recreation isn't ideal, but not really any other option in ORM 4. // Selecting a type used in where part of update statement - // (must match condidion in org.hibernate.persister.collection.BasicCollectionPersister.doUpdateRows). + // (must match condition in org.hibernate.persister.collection.BasicCollectionPersister#doUpdateRows). // See HHH-9474 Type whereType; if ( persister.hasIndex() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/context/internal/ThreadLocalSessionContext.java b/hibernate-core/src/main/java/org/hibernate/context/internal/ThreadLocalSessionContext.java index 40b6832e5c..c8e9caf7b5 100644 --- a/hibernate-core/src/main/java/org/hibernate/context/internal/ThreadLocalSessionContext.java +++ b/hibernate-core/src/main/java/org/hibernate/context/internal/ThreadLocalSessionContext.java @@ -108,7 +108,7 @@ public class ThreadLocalSessionContext extends AbstractCurrentSessionContext { } private boolean needsWrapping(Session session) { - // try to make sure we don't wrap and already wrapped session + // try to make sure we don't wrap an already wrapped session if ( Proxy.isProxyClass( session.getClass() ) ) { final InvocationHandler invocationHandler = Proxy.getInvocationHandler( session ); if ( invocationHandler != null && TransactionProtectionWrapper.class.isInstance( invocationHandler ) ) { @@ -182,7 +182,7 @@ public class ThreadLocalSessionContext extends AbstractCurrentSessionContext { SESSION_PROXY_INTERFACES, wrapper ); - // yick! need this for proper serialization/deserialization handling... + // yuck! need this for proper serialization/deserialization handling... wrapper.setWrapped( wrapped ); return wrapped; } @@ -315,7 +315,7 @@ public class ThreadLocalSessionContext extends AbstractCurrentSessionContext { else if ( "getStatistics".equals( methodName ) || "isOpen".equals( methodName ) || "getListeners".equals( methodName ) ) { - // allow these to go through the the real session no matter what + // allow these to go through the real session no matter what LOG.tracef( "Allowing invocation [%s] to proceed to real session", methodName ); } else if ( !realSession.isOpen() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java index 81b4f38c07..2c087e2ca3 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java @@ -428,7 +428,7 @@ public abstract class AbstractHANADialect extends Dialect { // stream passed in via // PreparedStatement.setCharacterStream(int,Reader,long) // after the stream has been processed. this causes problems later if we are - // using non-contexual lob creation and HANA then closes our StringReader. + // using non-contextual lob creation and HANA then closes our StringReader. // see test case LobLocatorTest private static class HANAClobTypeDescriptor extends ClobTypeDescriptor { @@ -932,8 +932,7 @@ public abstract class AbstractHANADialect extends Dialect { registerHanaKeywords(); - // createBlob() and createClob() are not supported by the HANA JDBC - // driver + // createBlob() and createClob() are not supported by the HANA JDBC driver getDefaultProperties().setProperty( AvailableSettings.NON_CONTEXTUAL_LOB_CREATION, "true" ); // getGeneratedKeys() is not supported by the HANA JDBC driver diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java index 36f9cd928f..5c7b6a81dd 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java @@ -143,7 +143,7 @@ abstract class AbstractTransactSQLDialect extends Dialect { @Override public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map keyColumnNames) { - // TODO: merge additional lockoptions support in Dialect.applyLocksToSql + // TODO: merge additional lock options support in Dialect.applyLocksToSql final Iterator itr = aliasedLockOptions.getAliasLockIterator(); final StringBuilder buffer = new StringBuilder( sql ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java index 3ff66a3812..124876597f 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java @@ -438,7 +438,7 @@ public class DB2Dialect extends Dialect { /** * {@inheritDoc} *

- * NOTE : DB2 is know to support parameters in the SELECT clause, but only in casted form + * NOTE : DB2 is known to support parameters in the SELECT clause, but only in casted form * (see {@link #requiresCastingOfParametersInSelectClause()}). */ @Override @@ -566,7 +566,7 @@ public class DB2Dialect extends Dialect { // we have one of: // * ASC + NULLS LAST // * DESC + NULLS FIRST - // so just drop the null precedence. *NOTE: we could pass along the null precedence here, + // so just drop the null precedence. *NOTE*: we could pass along the null precedence here, // but only DB2 9.7 or greater understand it; dropping it is more portable across DB2 versions return super.renderOrderByElement( expression, collation, order, NullPrecedence.NONE ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/IngresDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/IngresDialect.java index 9bc7973e9b..bd97084f5c 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/IngresDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/IngresDialect.java @@ -163,7 +163,7 @@ public class IngresDialect extends Dialect { getDefaultProperties().setProperty( Environment.USE_GET_GENERATED_KEYS, "false" ); // There is no support for a native boolean type that accepts values // of true, false or unknown. Using the tinyint type requires - // substitions of true and false. + // substitutions of true and false. getDefaultProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, "true=1,false=0" ); } 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 96eb77691c..89958c5142 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/InterbaseDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/InterbaseDialect.java @@ -42,7 +42,7 @@ public class InterbaseDialect extends Dialect { }; /** - * Constructs a InterbaseDialect + * Constructs an InterbaseDialect */ public InterbaseDialect() { super(); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java index 0027263e19..242212b618 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SybaseASE15Dialect.java @@ -60,7 +60,7 @@ public class SybaseASE15Dialect extends SybaseDialect { registerFunction( "coalesce", new VarArgsSQLFunction( "coalesce(", ",", ")" ) ); registerFunction( "col_length", new SQLFunctionTemplate( StandardBasicTypes.INTEGER, "col_length(?1, ?2)" ) ); registerFunction( "col_name", new SQLFunctionTemplate( StandardBasicTypes.STRING, "col_name(?1, ?2)" ) ); - // Sybase has created current_date and current_time inplace of getdate() + // Sybase has created current_date and current_time in place of getdate() registerFunction( "current_time", new NoArgSQLFunction( "current_time", StandardBasicTypes.TIME ) ); registerFunction( "current_date", new NoArgSQLFunction( "current_date", StandardBasicTypes.DATE ) ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/function/AbstractAnsiTrimEmulationFunction.java b/hibernate-core/src/main/java/org/hibernate/dialect/function/AbstractAnsiTrimEmulationFunction.java index d08d897a72..2382ecb0ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/function/AbstractAnsiTrimEmulationFunction.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/function/AbstractAnsiTrimEmulationFunction.java @@ -44,7 +44,7 @@ public abstract class AbstractAnsiTrimEmulationFunction implements SQLFunction { @Override public final String render(Type argumentType, List args, SessionFactoryImplementor factory) throws QueryException { // According to both the ANSI-SQL and JPA specs, trim takes a variable number of parameters between 1 and 4. - // at least one paramer (trimSource) is required. From the SQL spec: + // at least one parameter (trimSource) is required. From the SQL spec: // // ::= // TRIM diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/function/StandardAnsiSqlAggregationFunctions.java b/hibernate-core/src/main/java/org/hibernate/dialect/function/StandardAnsiSqlAggregationFunctions.java index f4f710bd6e..2e6b8591cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/function/StandardAnsiSqlAggregationFunctions.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/function/StandardAnsiSqlAggregationFunctions.java @@ -157,7 +157,7 @@ public class StandardAnsiSqlAggregationFunctions { public Type getReturnType(Type firstArgumentType, Mapping mapping) { final int jdbcType = determineJdbcTypeCode( firstArgumentType, mapping ); - // First allow the actual type to control the return value; the underlying sqltype could + // First allow the actual type to control the return value; the underlying sql type could // actually be different if ( firstArgumentType == StandardBasicTypes.BIG_INTEGER ) { return StandardBasicTypes.BIG_INTEGER; diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/identity/Chache71IdentityColumnSupport.java b/hibernate-core/src/main/java/org/hibernate/dialect/identity/Chache71IdentityColumnSupport.java index 400982b2ab..44f4ac7957 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/identity/Chache71IdentityColumnSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/identity/Chache71IdentityColumnSupport.java @@ -19,7 +19,7 @@ public class Chache71IdentityColumnSupport extends IdentityColumnSupportImpl { @Override public boolean hasDataTypeInIdentityColumn() { - // Whether this dialect has an Identity clause added to the data type or a completely seperate identity + // Whether this dialect has an Identity clause added to the data type or a completely separate identity // data type return true; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/CUBRIDLimitHandler.java b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/CUBRIDLimitHandler.java index 7fee33d78f..8e2f69014b 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/CUBRIDLimitHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/CUBRIDLimitHandler.java @@ -18,7 +18,7 @@ public class CUBRIDLimitHandler extends AbstractLimitHandler { public static final CUBRIDLimitHandler INSTANCE = new CUBRIDLimitHandler(); private CUBRIDLimitHandler() { - // NOP + // NOOP } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/FirstLimitHandler.java b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/FirstLimitHandler.java index 72af896aaa..430b634f28 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/FirstLimitHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/FirstLimitHandler.java @@ -17,7 +17,7 @@ public class FirstLimitHandler extends LegacyFirstLimitHandler { public static final FirstLimitHandler INSTANCE = new FirstLimitHandler(); private FirstLimitHandler() { - // NOP + // NOOP } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/LegacyFirstLimitHandler.java b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/LegacyFirstLimitHandler.java index dbf6dca837..62dfb2e419 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/LegacyFirstLimitHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/LegacyFirstLimitHandler.java @@ -18,7 +18,7 @@ public class LegacyFirstLimitHandler extends AbstractLimitHandler { public static final LegacyFirstLimitHandler INSTANCE = new LegacyFirstLimitHandler(); LegacyFirstLimitHandler() { - // NOP + // NOOP } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/NoopLimitHandler.java b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/NoopLimitHandler.java index b67a670dc2..c11a21ae68 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/NoopLimitHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/NoopLimitHandler.java @@ -21,7 +21,7 @@ public class NoopLimitHandler extends AbstractLimitHandler { public static final NoopLimitHandler INSTANCE = new NoopLimitHandler(); private NoopLimitHandler() { - // NOP + // NOOP } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/SQL2008StandardLimitHandler.java b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/SQL2008StandardLimitHandler.java index 54df6bc8a7..0ef5649126 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/pagination/SQL2008StandardLimitHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/pagination/SQL2008StandardLimitHandler.java @@ -21,7 +21,7 @@ public class SQL2008StandardLimitHandler extends AbstractLimitHandler { * Constructs a SQL2008StandardLimitHandler */ private SQL2008StandardLimitHandler() { - // NOP + // NOOP } @Override 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 daed5489f0..789f6c3c22 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 @@ -60,7 +60,7 @@ public class SQLServer2005LimitHandler extends AbstractLimitHandler { * Constructs a SQLServer2005LimitHandler */ public SQLServer2005LimitHandler() { - // NOP + // NOOP } @Override @@ -363,7 +363,7 @@ public class SQLServer2005LimitHandler extends AbstractLimitHandler { } else { // rather than taking the first match, we now iterate all matches - // until we determine a match that isn't considered "ignorable'. + // until we determine a match that isn't considered "ignorable". while ( matcher.find() && matcher.groupCount() > 0 ) { final int position = matcher.start(); if ( !isPositionIgnorable( ignoreRangeList, position ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/Collections.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/Collections.java index 2683657b8e..e474b6bad8 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/Collections.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/Collections.java @@ -279,7 +279,7 @@ public final class Collections { } if ( loadedPersister != null ) { - // we will need to remove ye olde entries + // we will need to remove the old entries entry.setDoremove( true ); if ( entry.isDorecreate() ) { LOG.trace( "Forcing collection initialization" ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/ForeignKeys.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/ForeignKeys.java index 814cccf238..5e1b545c31 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/ForeignKeys.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/ForeignKeys.java @@ -258,7 +258,7 @@ public final class ForeignKeys { return true; } - // todo : shouldnt assumed be revered here? + // todo : shouldn't assumed be reversed here? return !isTransient( entityName, entity, assumed, session ); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/Nullability.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/Nullability.java index 6c28d7ca8a..1d3a48b829 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/Nullability.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/Nullability.java @@ -81,9 +81,9 @@ public final class Nullability { * * * In the previous implementation, not-null stuffs where checked - * filtering by level one only updateable + * filtering by level one only updatable * or insertable columns. So setting a sub component as update="false" - * has no effect on not-null check if the main component had good checkeability + * has no effect on not-null check if the main component had good checkability * In this implementation, we keep this feature. * However, I never see any documentation mentioning that, but it's for * sure a limitation. @@ -104,7 +104,7 @@ public final class Nullability { GenerationTiming.NEVER == inMemoryValueGenerationStrategies[i].getGenerationTiming() ) { final Object value = values[i]; if ( !nullability[i] && value == null ) { - //check basic level one nullablilty + //check basic level one nullability throw new PropertyValueException( "not-null property references a null or transient value", persister.getEntityName(), diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java index ed0a5dc862..16e71d913c 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java @@ -352,7 +352,7 @@ public class StatefulPersistenceContext implements PersistenceContext { return dbValue; } else { - // for a mutable natural there is a likelihood that the the information will already be + // for a mutable natural id there is a likelihood that the information will already be // snapshot-cached. final int[] props = persister.getNaturalIdentifierProperties(); final Object[] entitySnapshot = getDatabaseSnapshot( id, persister ); @@ -530,8 +530,8 @@ public class StatefulPersistenceContext implements PersistenceContext { When a virtual method is called via an interface the JVM needs to resolve which concrete implementation to call. This takes CPU cycles and is a performance penalty. It also prevents method - in-ling which further degrades performance. Casting to an implementation and making a direct method call - removes the virtual call, and allows the methods to be in-lined. In this critical code path, it has a very + inlining which further degrades performance. Casting to an implementation and making a direct method call + removes the virtual call, and allows the methods to be inlined. In this critical code path, it has a very large impact on performance to make virtual method calls. */ if (persister.getEntityEntryFactory() instanceof MutableEntityEntryFactory) { @@ -1957,7 +1957,7 @@ public class StatefulPersistenceContext implements PersistenceContext { persister = locateProperPersister( persister ); - // 'justAddedLocally' is meant to handle the case where we would get double stats jounaling + // 'justAddedLocally' is meant to handle the case where we would get double stats journaling // from a single load event. The first put journal would come from the natural id resolution; // the second comes from the entity loading. In this condition, we want to avoid the multiple // 'put' stats incrementing. @@ -2164,7 +2164,7 @@ public class StatefulPersistenceContext implements PersistenceContext { // todo : couple of things wrong here: // 1) should be using access strategy, not plain evict.. - // 2) should prefer session-cached values if any (requires interaction from removeLocalNaturalIdCrossReference + // 2) should prefer session-cached values if any (requires interaction from removeLocalNaturalIdCrossReference) persister = locateProperPersister( persister ); final NaturalIdDataAccess naturalIdCacheAccessStrategy = persister.getNaturalIdCacheAccessStrategy(); diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultFlushEntityEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultFlushEntityEventListener.java index 1f0a604902..ced996e913 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultFlushEntityEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultFlushEntityEventListener.java @@ -529,7 +529,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener int[] dirty = persister.resolveAttributeIndexes( ( (SelfDirtinessTracker) entity ).$$_hibernate_getDirtyAttributes() ); // HHH-12051 - filter non-updatable attributes - // TODO: add Updateability to EnhancementContext and skip dirty tracking of those attributes + // TODO: add Updatability to EnhancementContext and skip dirty tracking of those attributes int count = 0; for ( int i : dirty ) { if ( persister.getPropertyUpdateability()[i] ) { @@ -573,7 +573,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener boolean dirtyCheckPossible = true; if ( dirtyProperties == null ) { - // Interceptor returned null, so do the dirtycheck ourself, if possible + // Interceptor returned null, so do the dirty check ourself, if possible try { session.getEventListenerManager().dirtyCalculationStart(); diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java index 0749eb0d97..11a78e2cb2 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java @@ -415,7 +415,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme // // This second condition is a special case which allows // an entity to be merged during the same transaction - // (though during a seperate operation) in which it was + // (though during a separate operation) in which it was // originally persisted/saved boolean changed = !persister.getVersionType().isSame( persister.getVersion( target ), diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultReplicateEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultReplicateEventListener.java index c7c65da7c5..10a919183f 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultReplicateEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultReplicateEventListener.java @@ -106,7 +106,7 @@ public class DefaultReplicateEventListener extends AbstractSaveEventListener imp ); // if can replicate, will result in a SQL UPDATE - // else do nothing (don't even reassociate object!) + // else do nothing (don't even re-associate object!) if ( canReplicate ) { performReplication( entity, id, realOldVersion, persister, replicationMode, source ); } diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DirtyCollectionSearchVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DirtyCollectionSearchVisitor.java index 79fbf5a9a3..73fb564b6e 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/DirtyCollectionSearchVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DirtyCollectionSearchVisitor.java @@ -40,12 +40,12 @@ public class DirtyCollectionSearchVisitor extends AbstractVisitor { final PersistentCollection persistentCollection; if ( type.isArrayType() ) { persistentCollection = session.getPersistenceContextInternal().getCollectionHolder( collection ); - // if no array holder we found an unwrappered array (this can't occur, + // if no array holder we found an unwrapped array (this can't occur, // because we now always call wrap() before getting to here) // return (ah==null) ? true : searchForDirtyCollections(ah, type); } else { - // if not wrappered yet, its dirty (this can't occur, because + // if not wrapped yet, its dirty (this can't occur, because // we now always call wrap() before getting to here) // return ( ! (obj instanceof PersistentCollection) ) ? //true : searchForDirtyCollections( (PersistentCollection) obj, type ); diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/OnLockVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/OnLockVisitor.java index 3cbb86ae47..4ca7cd2333 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/OnLockVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/OnLockVisitor.java @@ -45,26 +45,26 @@ public class OnLockVisitor extends ReattachVisitor { if ( isOwnerUnchanged( persistentCollection, persister, extractCollectionKeyFromOwner( persister ) ) ) { // a "detached" collection that originally belonged to the same entity if ( persistentCollection.isDirty() ) { - throw new HibernateException( "reassociated object has dirty collection" ); + throw new HibernateException( "re-associated object has dirty collection" ); } reattachCollection( persistentCollection, type ); } else { // a "detached" collection that belonged to a different entity - throw new HibernateException( "reassociated object has dirty collection reference" ); + throw new HibernateException( "re-associated object has dirty collection reference" ); } } else { // a collection loaded in the current session // can not possibly be the collection belonging // to the entity passed to update() - throw new HibernateException( "reassociated object has dirty collection reference" ); + throw new HibernateException( "re-associated object has dirty collection reference" ); } } else { // brand new collection //TODO: or an array!! we can't lock objects with arrays now?? - throw new HibernateException( "reassociated object has dirty collection reference (or an array)" ); + throw new HibernateException( "re-associated object has dirty collection reference (or an array)" ); } return null; diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/ProxyVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/ProxyVisitor.java index cf715aeb73..c462d5dd12 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/ProxyVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/ProxyVisitor.java @@ -72,7 +72,7 @@ public abstract class ProxyVisitor extends AbstractVisitor { } else { if ( !isCollectionSnapshotValid( collection ) ) { - throw new HibernateException( "could not reassociate uninitialized transient collection" ); + throw new HibernateException( "could not re-associate uninitialized transient collection" ); } CollectionPersister collectionPersister = session.getFactory() .getCollectionPersister( collection.getRole() ); diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlLexer.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlLexer.java index 0ef03d0cda..6c28fe6368 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlLexer.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlLexer.java @@ -44,13 +44,13 @@ class HqlLexer extends HqlBaseLexer { @Override public void panic() { - //overriden to avoid System.exit + //overridden to avoid System.exit panic( "CharScanner: panic" ); } @Override public void panic(String s) { - //overriden to avoid System.exit + //overridden to avoid System.exit throw new QueryException( s ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlSqlWalker.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlSqlWalker.java index bdb8ced180..5943b7ffb1 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlSqlWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlSqlWalker.java @@ -795,7 +795,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par } // After that, process the JOINs. - // Invoke a delegate to do the work, as this is farily complex. + // Invoke a delegate to do the work, as this is fairly complex. JoinProcessor joinProcessor = new JoinProcessor( this ); joinProcessor.processJoins( qn ); @@ -952,7 +952,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par parameterSpecs.add( 0, paramSpec ); if ( sessionFactoryHelper.getFactory().getDialect().requiresCastingOfParametersInSelectClause() ) { - // we need to wrtap the param in a cast() + // we need to wrap the param in a cast() MethodNode versionMethodNode = (MethodNode) getASTFactory().create( HqlSqlTokenTypes.METHOD_CALL, "(" @@ -1348,7 +1348,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par } public boolean isShallowQuery() { - // select clauses for insert statements should alwasy be treated as shallow + // select clauses for insert statements should always be treated as shallow return getStatementType() == INSERT || queryTranslatorImpl.isShallowQuery(); } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java index 09376e282e..fb36f64f1d 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java @@ -198,7 +198,7 @@ public class QueryTranslatorImpl implements FilterTranslator { // command executions. // // Possible to just move the sql generation for dml stuff, but for - // consistency-sake probably best to just move responsiblity for + // consistency-sake probably best to just move responsibility for // the generation phase completely into the delegates // (QueryLoader/StatementExecutor) themselves. Also, not sure why // QueryLoader currently even has a dependency on this at all; does @@ -538,7 +538,7 @@ public class QueryTranslatorImpl implements FilterTranslator { @Override public void validateScrollability() throws HibernateException { // Impl Note: allows multiple collection fetches as long as the - // entire fecthed graph still "points back" to a single + // entire fetched graph still "points back" to a single // root entity for return errorIfDML(); diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/SqlGenerator.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/SqlGenerator.java index 1ea2c5b1b4..709ebee290 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/SqlGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/SqlGenerator.java @@ -337,7 +337,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter { @Override protected void fromFragmentSeparator(AST a) { - // check two "adjecent" nodes at the top of the from-clause tree + // check two "adjacent" nodes at the top of the from-clause tree AST next = a.getNextSibling(); if ( next == null || !hasText( a ) ) { return; @@ -373,7 +373,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter { else if ( right.getRealOrigin() == left || ( right.getRealOrigin() != null && right.getRealOrigin() == left.getRealOrigin() ) ) { // right represents a joins originating from left; or - // both right and left reprersent joins originating from the same FromElement + // both right and left represent joins originating from the same FromElement if ( right.getJoinSequence() != null && right.getJoinSequence().isThetaStyle() ) { writeCrossJoinSeparator(); } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/AbstractNullnessCheckNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/AbstractNullnessCheckNode.java index 225a579a0e..7f9d81cd05 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/AbstractNullnessCheckNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/AbstractNullnessCheckNode.java @@ -25,7 +25,7 @@ public abstract class AbstractNullnessCheckNode extends UnaryLogicOperatorNode { @Override public void initialize() { // TODO : this really needs to be delayed until after we definitively know the operand node type; - // where this is currently a problem is parameters for which where we cannot unequivocally + // where this is currently a problem is parameters for which we cannot unequivocally // resolve an expected type Type operandType = extractDataType( getOperand() ); if ( operandType == null ) { @@ -135,7 +135,7 @@ public abstract class AbstractNullnessCheckNode extends UnaryLogicOperatorNode { return splits; } else { - throw new HibernateException( "dont know how to extract row value elements from node : " + operand ); + throw new HibernateException( "don't know how to extract row value elements from node : " + operand ); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryArithmeticOperatorNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryArithmeticOperatorNode.java index a9182fec78..f9ba3c4136 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryArithmeticOperatorNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryArithmeticOperatorNode.java @@ -167,7 +167,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression boolean rhsIsDateTime = isDateTimeType( rhType ); // handle the (assumed) valid cases: - // #1 - the only valid datetime addition synatx is one or the other is a datetime (but not both) + // #1 - the only valid datetime addition syntax is one or the other is a datetime (but not both) if ( getType() == HqlSqlTokenTypes.PLUS ) { // one or the other needs to be a datetime for us to get into this method in the first place... return lhsIsDateTime ? lhType : rhType; diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryLogicOperatorNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryLogicOperatorNode.java index 17e11d06f1..88ce4b46cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryLogicOperatorNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryLogicOperatorNode.java @@ -67,7 +67,7 @@ public class BinaryLogicOperatorNode extends AbstractSelectExpression implements protected final void mutateRowValueConstructorSyntaxesIfNecessary(Type lhsType, Type rhsType) { // TODO : this really needs to be delayed until after we definitively know all node types - // where this is currently a problem is parameters for which where we cannot unequivocally + // where this is currently a problem is parameters for which we cannot unequivocally // resolve an expected type SessionFactoryImplementor sessionFactory = getSessionFactoryHelper().getFactory(); if ( lhsType != null && rhsType != null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/CollectionSizeNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/CollectionSizeNode.java index a8f868ea66..2017d1288b 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/CollectionSizeNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/CollectionSizeNode.java @@ -53,7 +53,7 @@ public class CollectionSizeNode extends SqlNode implements SelectExpression { // where = alias_. // Note that `collectionPropertyMapping.toColumns(.., COLLECTION_SIZE)` returns the complete `count(...)` SQL - // expression, hence he expectation for a single expression regardless of the number of columns in the key. + // expression, hence the expectation for a single expression regardless of the number of columns in the key. final String collectionTableAlias = collectionOwnerFromElement.getFromClause() .getAliasGenerator() diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/ComponentJoin.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/ComponentJoin.java index a44391c5f1..8a1aee5279 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/ComponentJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/ComponentJoin.java @@ -121,7 +121,7 @@ public class ComponentJoin extends FromElement { public String renderScalarIdentifierSelect(int i) { String[] cols = getBasePropertyMapping().toColumns( getTableAlias(), getComponentProperty() ); StringBuilder buf = new StringBuilder(); - // For property references generate . as + // For property references generate . as for ( int j = 0; j < cols.length; j++ ) { final String column = cols[j]; if ( j > 0 ) { diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/DotNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/DotNode.java index 426b5c6838..a976147c92 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/DotNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/DotNode.java @@ -162,7 +162,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec // Set the attributes of the property reference expression. String propName = property.getText(); propertyName = propName; - // If the uresolved property path isn't set yet, just use the property name. + // If the unresolved property path isn't set yet, just use the property name. if ( propertyPath == null ) { propertyPath = propName; } @@ -559,7 +559,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec return true; } - // otherwise (subquery case) dont reuse the fromElement if we are processing the from-clause of the subquery + // otherwise (subquery case) don't reuse the fromElement if we are processing the from-clause of the subquery return getWalker().getCurrentClauseType() != SqlTokenTypes.FROM; } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/EntityJoinFromElement.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/EntityJoinFromElement.java index 3f09232112..5e60e6a1d7 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/EntityJoinFromElement.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/EntityJoinFromElement.java @@ -176,7 +176,7 @@ public class EntityJoinFromElement extends FromElement { else { // We know there is a fromFragment and that we shouldn't render a table group // This means the entity is polymorphic and the entity join is an inner join - // We move the with clause stuff to the where clause but still need to have a valid on condition + // We move the with clause stuff to the where clause but still need to have a valid condition buffer.append( "1=1" ); buffer.append( fromFragment ); diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java index 91237a8955..969c1507ba 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElement.java @@ -413,7 +413,7 @@ public class FromElement extends HqlSqlWalkerNode implements DisplayableNode, Pa else if ( !getWalker().isInFrom() ) { // HHH-276 : implied joins in a subselect where clause - The destination needs to be added // to the destination's from clause. - getFromClause().addChild( this ); // Not sure if this is will fix everything, but it works. + getFromClause().addChild( this ); // Not sure if this will fix everything, but it works. } else { // Otherwise, the destination node was implied by the FROM clause and the FROM clause processor @@ -612,7 +612,7 @@ public class FromElement extends HqlSqlWalkerNode implements DisplayableNode, Pa } public void setInProjectionList(boolean inProjectionList) { - // Do nothing, eplicit from elements are *always* in the projection list. + // Do nothing, explicit from elements are *always* in the projection list. } public boolean inProjectionList() { diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElementType.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElementType.java index 8f88d417e0..23e8ce656f 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElementType.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElementType.java @@ -364,7 +364,7 @@ class FromElementType { } this.queryableCollection = queryableCollection; if ( !queryableCollection.isOneToMany() ) { - // For many-to-many joins, use the tablename from the queryable collection for the default text. + // For many-to-many joins, use the table name from the queryable collection for the default text. fromElement.setText( queryableCollection.getTableName() + " " + getTableAlias() ); } } @@ -553,7 +553,7 @@ class FromElementType { // indexed, many-to-many collections must be treated specially here if the property to // be mapped touches on the index as we must adjust the alias to use the alias from - // the association table (which i different than the one passed in) + // the association table (which is different than the one passed in) if ( queryableCollection.isManyToMany() && queryableCollection.hasIndex() && SPECIAL_MANY2MANY_TREATMENT_FUNCTION_NAMES.contains( propertyName ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IdentNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IdentNode.java index 89c1e8be94..32b95144b6 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IdentNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IdentNode.java @@ -48,7 +48,7 @@ public class IdentNode extends FromReferenceNode implements SelectExpression { public void resolveIndex(AST parent) throws SemanticException { // An ident node can represent an index expression if the ident // represents a naked property ref - // *Note: this makes the assumption (which is currently the case + // *Note*: this makes the assumption (which is currently the case // in the hql-sql grammar) that the ident is first resolved // itself (addrExpr -> resolve()). The other option, if that // changes, is to call resolve from here; but it is @@ -373,7 +373,7 @@ public class IdentNode extends FromReferenceNode implements SelectExpression { public void setScalarColumnText(int i) throws SemanticException { if (nakedPropertyRef) { - // do *not* over-write the column text, as that has already been + // do *not* overwrite the column text, as that has already been // "rendered" during resolve ColumnHelper.generateSingleScalarColumn(this, i); } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IntoClause.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IntoClause.java index 02c38142d4..71e6f1b06f 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IntoClause.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IntoClause.java @@ -203,13 +203,13 @@ public class IntoClause extends HqlSqlWalkerNode implements DisplayableNode { // really there are two situations where it should be ok to allow the insertion // into properties defined on a superclass: // 1) union-subclass with an abstract root entity - // 2) discrim-subclass + // 2) discriminator-subclass // // #1 is handled already because of the fact that // UnionSubclassPersister alreay always returns 0 // for this call... // - // we may want to disallow it for discrim-subclass just for + // we may want to disallow it for discriminator-subclass just for // consistency-sake (currently does not work anyway)... return persister.getSubclassPropertyTableNumber( propertyName ) != 0; } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/MapKeyEntityFromElement.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/MapKeyEntityFromElement.java index d6624c25c8..dd1996fed7 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/MapKeyEntityFromElement.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/MapKeyEntityFromElement.java @@ -72,7 +72,7 @@ public class MapKeyEntityFromElement extends FromElement { rhsAlias ); -// String[] joinColumns = determineJoinColuns( collectionPersister, joinTableAlias ); +// String[] joinColumns = determineJoinColumns( collectionPersister, joinTableAlias ); // todo : assumes columns, no formulas String[] joinColumns = collectionPersister.getIndexColumnNames( collectionFromElement.getCollectionTableAlias() ); diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/SelectClause.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/SelectClause.java index df33118d0e..6d4dfb7d23 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/SelectClause.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/SelectClause.java @@ -117,7 +117,7 @@ public class SelectClause extends SelectExpressionList { throw new IllegalStateException( "SelectClause was already prepared!" ); } - //explicit = true; // This is an explict Select. + //explicit = true; // This is an explicit Select. //ArrayList sqlResultTypeList = new ArrayList(); ArrayList queryReturnTypeList = new ArrayList(); @@ -177,7 +177,7 @@ public class SelectClause extends SelectExpressionList { } } - //init the aliases, after initing the constructornode + //init the aliases, after initiating the constructorNode initAliases( selectExpressions ); if ( !getWalker().isShallowQuery() ) { @@ -196,7 +196,7 @@ public class SelectClause extends SelectExpressionList { final FromElement origin; if ( fromElement.getRealOrigin() == null ) { // work around that crazy issue where the tree contains - // "empty" FromElements (no text); afaict, this is caused + // "empty" FromElements (no text); AFAICT, this is caused // by FromElementFactory.createCollectionJoin() if ( fromElement.getOrigin() == null ) { throw new QueryException( "Unable to determine origin of join fetch [" + fromElement.getDisplayText() + "]" ); diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/ColumnHelper.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/ColumnHelper.java index b946ea87f2..572a3fa800 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/ColumnHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/ColumnHelper.java @@ -43,7 +43,7 @@ public final class ColumnHelper { ASTFactory factory = node.getASTFactory(); AST n = node; n.setText( sqlColumns[0] ); // Use the DOT node to emit the first column name. - // Create the column names, folled by the column aliases. + // Create the column names, filled by the column aliases. for ( int j = 0; j < sqlColumns.length; j++ ) { if ( j > 0 ) { n = ASTUtil.createSibling( factory, SqlTokenTypes.SQL_TOKEN, sqlColumns[j], n ); diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/JoinProcessor.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/JoinProcessor.java index bc7d3cb3d9..0382929e75 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/JoinProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/JoinProcessor.java @@ -228,7 +228,7 @@ public class JoinProcessor implements SqlTokenTypes { while ( liter.hasNext() ) { FromElement fromElement = liter.next(); - // We found an implied from element that is used in the WITH clause of another from element, so it need to become part of it's join sequence + // We found an implied from element that is used in the WITH clause of another from element, so it need to become part of its join sequence if ( fromElement instanceof ImpliedFromElement && fromElement.getOrigin().getWithClauseFragment() != null && fromElement.getOrigin().getWithClauseFragment().contains( fromElement.getTableAlias() ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SessionFactoryHelper.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SessionFactoryHelper.java index 9fb7b590c0..355632ae98 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SessionFactoryHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SessionFactoryHelper.java @@ -75,7 +75,7 @@ public class SessionFactoryHelper { if ( persister.getDiscriminatorType() != null ) { String discrimColumnName = persister.getDiscriminatorColumnName(); // Needed the "clazz_" check to work around union-subclasses - // TODO : is there a way to tell whether a persister is truly discrim-column based inheritence? + // TODO : is there a way to tell whether a persister is truly discriminator-column based inheritance? if ( discrimColumnName != null && !"clazz_".equals( discrimColumnName ) ) { return true; } 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 604fa394ca..f25a2e7b80 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 @@ -165,7 +165,7 @@ public class FromParser implements Parser { // (AS is always optional, for consistency with SQL/OQL) // process the "new" HQL style where aliases are assigned - // _after_ the class name or path expression ie. using + // _after_ the class name or path expression, ie. using // the AS construction if ( entityName != null ) { @@ -315,8 +315,8 @@ public class FromParser implements Parser { public void end(QueryTranslatorImpl q) { if ( afterMemberDeclarations ) { - //The exception throwned by the AST query translator contains the error token location, represented by line and column, - //but it hard to get that info here. + //The exception thrown by the AST query translator contains the error token location, represented by line and column, + //but it is hard to get that info here. throw new QueryException( "alias not specified for IN" ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/PathExpressionParser.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/PathExpressionParser.java index bfbd803dc8..46b69e3fbe 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/PathExpressionParser.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/classic/PathExpressionParser.java @@ -30,13 +30,13 @@ import org.hibernate.type.Type; public class PathExpressionParser implements Parser { //TODO: this class does too many things! we need a different - //kind of path expression parser for each of the diffferent + //kind of path expression parser for each of the different //ways in which path expressions can occur //We should actually rework this class to not implement Parser //and just process path expressions in the most convenient way. - //The class is now way to complex! + //The class is now way too complex! private int dotcount; private String currentName; 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 11fe2c5f2f..cebc8808f4 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 @@ -834,7 +834,7 @@ public class QueryTranslatorImpl extends BasicLoader implements FilterTranslator //there _was_ a select clause Iterator iter = scalarSelectTokens.iterator(); int c = 0; - boolean nolast = false; //real hacky... + boolean nolast = false; //really hacky... int parenCount = 0; // used to count the nesting of parentheses while ( iter.hasNext() ) { Object next = iter.next(); diff --git a/hibernate-core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java index b9226b338e..edb29441f8 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java @@ -40,7 +40,7 @@ public abstract class AbstractUUIDGenerator implements IdentifierGenerator { /** * Unique across JVMs on this machine (unless they load this class - * in the same quater second - very unlikely) + * in the same quarter second - very unlikely) */ protected int getJVM() { return JVM; diff --git a/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java index 7dfbe44da6..6c7c1000d8 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java @@ -318,7 +318,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera if ( table == null ) { table = namespace.createTable( qualifiedTableName.getObjectName(), false ); - // todo : note sure the best solution here. do we add the columns if missing? other? + // todo : not sure the best solution here. do we add the columns if missing? other? table.setPrimaryKey( new PrimaryKey( table ) ); final Column pkColumn = new ExportableColumn( diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/HiLoOptimizer.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/HiLoOptimizer.java index 1cf6806254..603323123a 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/HiLoOptimizer.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/HiLoOptimizer.java @@ -89,7 +89,7 @@ public class HiLoOptimizer extends AbstractOptimizer { } // upperLimit defines the upper end of the bucket values generationState.upperLimit = generationState.lastSourceValue.copy().multiplyBy( incrementSize ).increment(); - // initialize value to the low end of the bucket + // initialize value to the lower end of the bucket generationState.value = generationState.upperLimit.copy().subtract( incrementSize ); } else if ( ! generationState.upperLimit.gt( generationState.value ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/NoopOptimizer.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/NoopOptimizer.java index ad3a8200b6..8b51695034 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/NoopOptimizer.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/NoopOptimizer.java @@ -34,7 +34,7 @@ public final class NoopOptimizer extends AbstractOptimizer { // IMPL NOTE : this method is called concurrently and is // not synchronized. It is very important to work on the // local variable: the field lastSourceValue is not - // reliable as it might be mutated by multipled threads. + // reliable as it might be mutated by multiple threads. // The lastSourceValue field is only accessed by tests, // so this is not a concern. IntegralDataTypeHolder value = callback.getNextValue(); diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledOptimizer.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledOptimizer.java index 057aac0a8c..59e90f1cc3 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledOptimizer.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/PooledOptimizer.java @@ -72,7 +72,7 @@ public class PooledOptimizer extends AbstractOptimizer implements InitialValueAw if ( generationState.hiValue == null ) { generationState.value = callback.getNextValue(); // unfortunately not really safe to normalize this - // to 1 as an initial value like we do the others + // to 1 as an initial value like we do for the others // because we would not be able to control this if // we are using a sequence... if ( generationState.value.lt( 1 ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java index 47e5a69bd0..5a96109195 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java @@ -737,7 +737,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab if ( table == null ) { table = namespace.createTable( qualifiedTableName.getObjectName(), false ); - // todo : note sure the best solution here. do we add the columns if missing? other? + // todo : not sure the best solution here. do we add the columns if missing? other? final Column segmentColumn = new ExportableColumn( database, table, diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java index 03c61d9d5b..9ad4e9f156 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java @@ -197,7 +197,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont this.transactionCoordinator = sharedOptions.getTransactionCoordinator(); this.jdbcCoordinator = sharedOptions.getJdbcCoordinator(); - // todo : "wrap" the transaction to no-op comit/rollback attempts? + // todo : "wrap" the transaction to no-op commit/rollback attempts? this.currentHibernateTransaction = sharedOptions.getTransaction(); if ( sharedOptions.shouldAutoJoinTransactions() ) { @@ -243,7 +243,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont private StatementInspector interpret(StatementInspector statementInspector) { if ( statementInspector == null ) { // If there is no StatementInspector specified, map to the call - // to the (deprecated) Interceptor #onPrepareStatement method + // to the (deprecated) Interceptor#onPrepareStatement method return (StatementInspector) interceptor::onPrepareStatement; } return statementInspector; @@ -286,7 +286,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont @Override public UUID getSessionIdentifier() { if ( this.sessionIdentifier == null ) { - //Lazily initialized: otherwise all the UUID generations will cause of significant amount of contention. + //Lazily initialized: otherwise all the UUID generations will cause significant amount of contention. this.sessionIdentifier = StandardRandomStrategy.INSTANCE.generateUUID( null ); } return sessionIdentifier; @@ -853,7 +853,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont } } else if ( queryPlan.getTranslators()[0].getReturnTypes().length == 1 ) { - // if we have only a single return expression, its java type should match with the requested type + // if we have only a single return expression, its java type should match the requested type final Type queryResultType = queryPlan.getTranslators()[0].getReturnTypes()[0]; if ( !resultClass.isAssignableFrom( queryResultType.getReturnedClass() ) ) { throw new IllegalArgumentException( diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index 796787f6e7..be124c9443 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -451,7 +451,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { public Session openSession() throws HibernateException { final CurrentTenantIdentifierResolver currentTenantIdentifierResolver = getCurrentTenantIdentifierResolver(); - //We can only use reuse the defaultSessionOpenOptions as a constant when there is no TenantIdentifierResolver + //We can only reuse the defaultSessionOpenOptions as a constant when there is no TenantIdentifierResolver if ( currentTenantIdentifierResolver != null ) { return this.withOptions().openSession(); } @@ -462,7 +462,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { public Session openTemporarySession() throws HibernateException { final CurrentTenantIdentifierResolver currentTenantIdentifierResolver = getCurrentTenantIdentifierResolver(); - //We can only use reuse the defaultSessionOpenOptions as a constant when there is no TenantIdentifierResolver + //We can only reuse the defaultSessionOpenOptions as a constant when there is no TenantIdentifierResolver if ( currentTenantIdentifierResolver != null ) { return buildTemporarySessionOpenOptions() .openSession(); @@ -1097,7 +1097,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { return interceptor; } - // prefer the SF-scoped interceptor, prefer that to any Session-scoped interceptor prototype + // prefer the SessionFactory-scoped interceptor, prefer that to any Session-scoped interceptor prototype final Interceptor optionsInterceptor = options.getInterceptor(); if ( optionsInterceptor != null && optionsInterceptor != EmptyInterceptor.INSTANCE ) { return optionsInterceptor; @@ -1308,7 +1308,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { @SuppressWarnings("unchecked") public T connectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) { // NOTE : Legacy behavior (when only ConnectionReleaseMode was exposed) was to always acquire a - // Connection using ConnectionAcquisitionMode.AS_NEEDED.. + // Connection using ConnectionAcquisitionMode.AS_NEEDED. final PhysicalConnectionHandlingMode handlingMode = PhysicalConnectionHandlingMode.interpret( ConnectionAcquisitionMode.AS_NEEDED, @@ -1376,7 +1376,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor { @SuppressWarnings("unchecked") public T clearEventListeners() { if ( listeners == null ) { - //Needs to initialize explicitly to an empty list as otherwise "null" immplies the default listeners will be applied + //Needs to initialize explicitly to an empty list as otherwise "null" implies the default listeners will be applied this.listeners = new ArrayList( 3 ); } else { diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 0ea06c1f23..8be3794dfa 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -1915,7 +1915,7 @@ public class SessionImpl } // Since isLookupByNaturalKey is true there can be only one CriterionEntry and getCriterion() will - // return an instanceof NaturalIdentifier + // return an instance of NaturalIdentifier final CriterionEntry criterionEntry = criteria.iterateExpressionEntries().next(); final NaturalIdentifier naturalIdentifier = (NaturalIdentifier) criterionEntry.getCriterion(); @@ -1936,7 +1936,7 @@ public class SessionImpl final Object naturalIdValue = naturalIdValues.get( naturalIdProperty ); if ( naturalIdValue == null ) { - // A NaturalId property is missing from the critera query, can't use NaturalIdLoadAccess + // A NaturalId property is missing from the criteria query, can't use NaturalIdLoadAccess return null; } @@ -3323,7 +3323,7 @@ public class SessionImpl return loadAccess.load( (Serializable) primaryKey ); } catch ( EntityNotFoundException ignored ) { - // DefaultLoadEventListener.returnNarrowedProxy may throw ENFE (see HHH-7861 for details), + // DefaultLoadEventListener#returnNarrowedProxy() may throw ENFE (see HHH-7861 for details), // which find() should not throw. Find() should return null if the entity was not found. if ( log.isDebugEnabled() ) { String entityName = entityClass != null ? entityClass.getName(): null; @@ -3345,7 +3345,7 @@ public class SessionImpl } catch ( JDBCException e ) { if ( accessTransaction().isActive() && accessTransaction().getRollbackOnly() ) { - // Assume this is the similar to the WildFly / IronJacamar "feature" described under HHH-12472. + // Assume this is similar to the WildFly / IronJacamar "feature" described under HHH-12472. // Just log the exception and return null. if ( log.isDebugEnabled() ) { log.debug( "JDBCException was thrown for a transaction marked for rollback; " + @@ -3788,9 +3788,9 @@ public class SessionImpl loadQueryInfluencers = (LoadQueryInfluencers) ois.readObject(); - // LoadQueryInfluencers.getEnabledFilters() tries to validate each enabled - // filter, which will fail when called before FilterImpl.afterDeserialize( factory ); - // Instead lookup the filter by name and then call FilterImpl.afterDeserialize( factory ). + // LoadQueryInfluencers#getEnabledFilters() tries to validate each enabled + // filter, which will fail when called before FilterImpl#afterDeserialize( factory ); + // Instead lookup the filter by name and then call FilterImpl#afterDeserialize( factory ). for ( String filterName : loadQueryInfluencers.getEnabledFilterNames() ) { ( (FilterImpl) loadQueryInfluencers.getEnabledFilter( filterName ) ).afterDeserialize( getFactory() ); } 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 31e9d81841..1299b5648b 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 @@ -156,7 +156,7 @@ public final class StringHelper { // enclosed in parentheses (HHH-10383) // Examples: // 1) "... IN (?1", we assume that "?1" does not need to be enclosed because there - // there is already a right-parenthesis; we assume there will be a matching right-parenthesis. + // is already a right-parenthesis; we assume there will be a matching right-parenthesis. // 2) "... IN ?1", we assume that "?1" needs to be enclosed in parentheses, because there // is no left-parenthesis. @@ -441,8 +441,8 @@ public final class StringHelper { if ( string == null ) { return 0; } - // Impl note: takes advantage of the fact that an escpaed single quote - // embedded within a quote-block can really be handled as two seperate + // Impl note: takes advantage of the fact that an escaped single quote + // embedded within a quote-block can really be handled as two separate // quote-blocks for the purposes of this method... int count = 0; int stringLength = string.length(); @@ -601,7 +601,7 @@ public final class StringHelper { */ private static String cleanAlias(String alias) { char[] chars = alias.toCharArray(); - // short cut check... + // shortcut check... if ( !Character.isLetter( chars[0] ) ) { for ( int i = 1; i < chars.length; i++ ) { // as soon as we encounter our first letter, return the substring diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/type/PrimitiveWrapperHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/type/PrimitiveWrapperHelper.java index 733c9fe518..dc2f9d7de6 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/type/PrimitiveWrapperHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/type/PrimitiveWrapperHelper.java @@ -242,7 +242,7 @@ public final class PrimitiveWrapperHelper { return (PrimitiveWrapperDescriptor) DoubleDescriptor.INSTANCE; } - // most likely void.class, which we can't really handle here + // most likely Void.class, which we can't really handle here throw new IllegalArgumentException( "Unrecognized wrapper type class : " + wrapperClass.getName() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/xml/ErrorLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/util/xml/ErrorLogger.java index 07bd1f540a..9ba04a315c 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/xml/ErrorLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/xml/ErrorLogger.java @@ -31,7 +31,7 @@ public class ErrorLogger implements ErrorHandler, Serializable { ErrorLogger.class.getName() ); - // lazily initalized + // lazily initialized private List errors; private String file; diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java index afc4ffb3ea..aa280a13f1 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java @@ -199,7 +199,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil Map mergedIntegrationSettings = null; Properties properties = persistenceUnit.getProperties(); if ( properties != null ) { - // original integratin setting entries take precedence + // original integration setting entries take precedence mergedIntegrationSettings = new HashMap( properties ); mergedIntegrationSettings.putAll( integrationSettings ); } @@ -884,7 +884,7 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil // `IS_JTA_TXN_COORD` is a value set during `#normalizeTransactionCoordinator` to indicate whether // the execution environment "is JTA" as best as it can tell.. // - // we use this value when JTA was not explicitly specified in regards the DataSource + // we use this value when JTA was not explicitly specified in regards to the DataSource final boolean isJtaTransactionCoordinator = (boolean) mergedSettings.configurationValues.remove( IS_JTA_TXN_COORD ); final boolean isJta = useJtaDataSource == null ? isJtaTransactionCoordinator : useJtaDataSource; diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/internal/enhance/EnhancingClassTransformerImpl.java b/hibernate-core/src/main/java/org/hibernate/jpa/internal/enhance/EnhancingClassTransformerImpl.java index 25346bba16..65e2f76c87 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/internal/enhance/EnhancingClassTransformerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/internal/enhance/EnhancingClassTransformerImpl.java @@ -36,7 +36,7 @@ public class EnhancingClassTransformerImpl implements ClassTransformer { byte[] classfileBuffer) throws IllegalClassFormatException { // The first design had the enhancer as a class variable. That approach had some goods and bads. - // We don't had to create an enhancer for each class, but on the other end it would stay in memory forever. + // We don't have to create an enhancer for each class, but on the other end it would stay in memory forever. // It also assumed that all calls come from the same class loader, which is fair, but this makes it more robust. try { diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/internal/util/XmlHelper.java b/hibernate-core/src/main/java/org/hibernate/jpa/internal/util/XmlHelper.java index 3269811cc1..80057bb386 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/internal/util/XmlHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/internal/util/XmlHelper.java @@ -38,7 +38,7 @@ public final class XmlHelper { return null; } // getElementsByTagName gives the corresponding elements in the whole - // descendance. We want only children + // descendants. We want only children NodeList children = element.getChildNodes(); ArrayList goodChildren = new ArrayList(); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java index c0af913a8b..ca27b446ad 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java @@ -1975,7 +1975,7 @@ public abstract class Loader { final String result = persister.getSubclassForDiscriminatorValue( discriminatorValue ); if ( result == null ) { - //woops we got an instance of another class hierarchy branch + //whoops we got an instance of another class hierarchy branch throw new WrongClassException( "Discriminator: " + discriminatorValue, id, diff --git a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaLoader.java index 6a8b9e5120..6ca047fb1c 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaLoader.java @@ -49,7 +49,7 @@ public class CriteriaLoader extends OuterJoinLoader { // interface //NOTE: unlike all other Loaders, this one is NOT - // multithreaded, or cacheable!! + // multi-threaded, or cacheable!! private final CriteriaQueryTranslator translator; private final Set querySpaces; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java index fffd36b346..0d88f8b8a5 100755 --- a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java @@ -213,7 +213,7 @@ public class CriteriaQueryTranslator implements CriteriaQuery { } if ( parent.equals( rootCriteria ) ) { - // if its the root criteria, we are done + // if it's the root criteria, we are done return path; } else { @@ -255,7 +255,7 @@ public class CriteriaQueryTranslator implements CriteriaQuery { final AssociationType atype = (AssociationType) type; final CollectionType ctype = type.isCollectionType() ? (CollectionType)type : null; final Type elementType = (ctype != null) ? ctype.getElementType( sessionFactory ) : null; - // is the association a collection of components or value-types? (i.e a colloction of valued types?) + // is the association a collection of components or value-types? (i.e a collection of valued types?) if ( ctype != null && elementType.isComponentType() ) { provider = new ComponentCollectionCriteriaInfoProvider( helper.getCollectionPersister(ctype.getRole()) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/loader/custom/CustomLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/custom/CustomLoader.java index e30802a143..d8d84ddd83 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/custom/CustomLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/custom/CustomLoader.java @@ -52,7 +52,7 @@ import org.hibernate.type.Type; */ public class CustomLoader extends Loader { - // Currently *not* cachable if autodiscover types is in effect (e.g. "select * ...") + // Currently *not* cacheable if auto-discover types are in effect (e.g. "select * ...") private final String sql; private final Set querySpaces = new HashSet<>(); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java b/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java index 216d72a0cf..73efc374e5 100755 --- a/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryParser.java @@ -74,8 +74,8 @@ public class SQLQueryParser { return processedSql; } - // TODO: should "record" how many properties we have reffered to - and if we - // don't get'em'all we throw an exception! Way better than trial and error ;) + // TODO: should "record" how many properties we have referred to - and if we + // don't get them all we throw an exception! Way better than trial and error ;) protected String substituteBrackets(String sqlQuery) throws QueryException { if ( PREPARED_STATEMENT_PATTERN.matcher( sqlQuery.trim() ).matches() ) { @@ -94,7 +94,7 @@ public class SQLQueryParser { break; } - // apend everything up until the next encountered open brace + // append everything up until the next encountered open brace result.append( sqlQuery.substring( curr, left ) ); if ( ( right = sqlQuery.indexOf( '}', left + 1 ) ) < 0 ) { @@ -206,7 +206,7 @@ public class SQLQueryParser { else { String[] columnAliases; - // Let return-propertys override whatever the persister has for aliases. + // Let return-properties override whatever the persister has for aliases. columnAliases = ( String[] ) fieldResults.get(propertyName); if ( columnAliases==null ) { columnAliases = collectionPersister.getCollectionPropertyColumnAliases( propertyName, collectionSuffix ); @@ -247,7 +247,7 @@ public class SQLQueryParser { String[] columnAliases; - // Let return-propertys override whatever the persister has for aliases. + // Let return-propertiess override whatever the persister has for aliases. columnAliases = (String[]) fieldResults.get( propertyName ); if ( columnAliases == null ) { columnAliases = persister.getSubclassPropertyColumnAliases( propertyName, suffix ); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryReturnProcessor.java b/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryReturnProcessor.java index fdafd4203b..be483e481e 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryReturnProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/custom/sql/SQLQueryReturnProcessor.java @@ -565,7 +565,7 @@ public class SQLQueryReturnProcessor { throw new HibernateException( "Owner alias [" + ownerAlias + "] is unknown for alias [" + alias + "]" ); } - // If this return's alias has not been processed yet, do so b4 further processing of this return + // If this return's alias has not been processed yet, do so before further processing of this return if ( !alias2Persister.containsKey( ownerAlias ) ) { NativeSQLQueryNonScalarReturn ownerReturn = ( NativeSQLQueryNonScalarReturn ) alias2Return.get(ownerAlias); processReturn( ownerReturn ); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/LoadQueryJoinAndFetchProcessor.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/LoadQueryJoinAndFetchProcessor.java index 333f3384d0..48616c2c0f 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/LoadQueryJoinAndFetchProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/LoadQueryJoinAndFetchProcessor.java @@ -607,7 +607,7 @@ public class LoadQueryJoinAndFetchProcessor { // when processing the Join part of this we are able to look up the "lhs table alias" because we know // the 'lhs' QuerySpace. // - // Good idea to be able resolve a Join by lookup on the rhs and lhs uid? If so, Fetch + // Good idea to be able to resolve a Join by lookup on the rhs and lhs uid? If so, Fetch // for many-to-many we have 3 table aliases. By way of example, consider a normal m-n: User<->Role // where User is the FetchOwner and Role (User.roles) is the Fetch. We'd have: diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/CollectionReferenceInitializerImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/CollectionReferenceInitializerImpl.java index 2d97519e84..2f9fd983e3 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/CollectionReferenceInitializerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/CollectionReferenceInitializerImpl.java @@ -128,7 +128,7 @@ public class CollectionReferenceInitializerImpl implements CollectionReferenceIn // todo : try org.hibernate.loader.plan.exec.process.spi.ResultSetProcessingContext.getOwnerProcessingState() ?? // -- specifically to return its ResultSetProcessingContext.EntityReferenceProcessingState#getEntityInstance() if ( collectionOwner == null ) { - //TODO: This is assertion is disabled because there is a bug that means the + //TODO: This assertion is disabled because there is a bug that means the // original owner of a transient, uninitialized collection is not known // if the collection is re-referenced by a different object associated // with the current Session diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Collection.java b/hibernate-core/src/main/java/org/hibernate/mapping/Collection.java index 78d96cefe8..8a1ad88a50 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Collection.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Collection.java @@ -332,8 +332,8 @@ public abstract class Collection implements Fetchable, Value, Filterable { int i = 0; while ( iterator.hasNext() ) { Selectable s = iterator.next(); - // exclude formulas and coluns that are not insertable or updatable - // since these values can be be repeated (HHH-5393) + // exclude formulas and columns that are not insertable or updatable + // since these values can be repeated (HHH-5393) if ( !s.isFormula() && ( insertability[i] || updatability[i] ) ) { Column col = (Column) s; if ( !distinctColumns.add( col.getName() ) ) { 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 9c3fd15bc4..997aae316b 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java @@ -217,10 +217,10 @@ public class Column implements Selectable, Serializable, Cloneable { } /** - * Returns the underlying columns sqltypecode. - * If null, it is because the sqltype code is unknown. + * Returns the underlying columns SqlTypeCode. + * If null, it is because the SqlTypeCode is unknown. *

- * Use #getSqlTypeCode(Mapping) to retrieve the sqltypecode used + * Use #getSqlTypeCode(Mapping) to retrieve the SqlTypeCode used * for the columns associated Value/Type. * * @return sqlTypeCode if it is set, otherwise null. diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java b/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java index 44c5db907b..73d891f1a6 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java @@ -121,7 +121,7 @@ public class ForeignKey extends Constraint { } /** - * Validates that columnspan of the foreignkey and the primarykey is the same. + * Validates that column span of the foreign key and the primary key is the same. *

* Furthermore it aligns the length of the underlying tables columns. */ diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java b/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java index a51f158e50..d33a5fd347 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java @@ -96,7 +96,7 @@ public class MappedSuperclass { } public Property getIdentifierProperty() { - //get direct identifiermapper or the one from the super mappedSuperclass + //get direct identifierMapper or the one from the super mappedSuperclass // or the one from the super persistentClass Property propagatedIdentifierProp = identifierProperty; if ( propagatedIdentifierProp == null ) { @@ -142,7 +142,7 @@ public class MappedSuperclass { } public Component getIdentifierMapper() { - //get direct identifiermapper or the one from the super mappedSuperclass + //get direct identifierMapper or the one from the super mappedSuperclass // or the one from the super persistentClass Component propagatedMapper = identifierMapper; if ( propagatedMapper == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/OneToMany.java b/hibernate-core/src/main/java/org/hibernate/mapping/OneToMany.java index a4497a9b19..3f0d820474 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/OneToMany.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/OneToMany.java @@ -74,7 +74,7 @@ public class OneToMany implements Value { } public void createForeignKey() { - // no foreign key element of for a one-to-many + // no foreign key element for a one-to-many } public Iterator getColumnIterator() { diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java index e39f074652..6ab1e7de76 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java @@ -1006,6 +1006,6 @@ public abstract class PersistentClass implements AttributeContainer, Serializabl this.superMappedSuperclass = superMappedSuperclass; } - // End of @Mappedsuperclass support + // End of @MappedSuperclass support } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Property.java b/hibernate-core/src/main/java/org/hibernate/mapping/Property.java index f18d27046b..0c14c9bc61 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Property.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Property.java @@ -162,7 +162,7 @@ public class Property implements Serializable, MetaAttributable { public boolean isUpdateable() { // if the property mapping consists of all formulas, - // make it non-updateable + // make it non-updatable return updateable && !ArrayHelper.isAllFalse( value.getColumnUpdateability() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Set.java b/hibernate-core/src/main/java/org/hibernate/mapping/Set.java index 1b891a502d..7b6d7608e9 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Set.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Set.java @@ -86,7 +86,7 @@ public class Set extends Collection { } if ( pk.getColumnSpan() == getKey().getColumnSpan() ) { //for backward compatibility, allow a set with no not-null - //element columns, using all columns in the row locater SQL + //element columns, using all columns in the row locator SQL //TODO: create an implicit not null constraint on all cols? } else { diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java index d9f8b65ec9..3db302a5d4 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java @@ -531,7 +531,7 @@ public class SimpleValue implements KeyValue { .getServiceRegistry() .getService( ClassLoaderService.class ) ).getName(); - // todo : to fully support isNationalized here we need do the process hinted at above + // todo : to fully support isNationalized here we need to do the process hinted at above // essentially, much of the logic from #buildAttributeConverterTypeAdapter wrt resolving // a (1) SqlTypeDescriptor, a (2) JavaTypeDescriptor and dynamically building a BasicType // combining them. @@ -633,7 +633,7 @@ public class SimpleValue implements KeyValue { jdbcTypeCode = NationalizedTypeMappings.toNationalizedTypeCode( jdbcTypeCode ); } - // find the standard SqlTypeDescriptor for that JDBC type code (allow itr to be remapped if needed!) + // find the standard SqlTypeDescriptor for that JDBC type code (allow it to be remapped if needed!) final SqlTypeDescriptor sqlTypeDescriptor = getMetadata() .getMetadataBuildingOptions() .getServiceRegistry() diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java index 99985b18e7..455b50305f 100755 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AttributeFactory.java @@ -517,7 +517,7 @@ public class AttributeFactory { final org.hibernate.type.Type elementType = elementValue.getType(); // First, determine the type of the elements and use that to help determine the - // collection type) + // collection type final Attribute.PersistentAttributeType elementPersistentAttributeType; final Attribute.PersistentAttributeType persistentAttributeType; if ( elementType.isAnyType() ) { @@ -862,7 +862,7 @@ public class AttributeFactory { } }; - // interpret the key, if one + // interpret the key, if one exists if ( keyPersistentAttributeType != null ) { this.keyValueContext = new ValueContext() { public Value getHibernateValue() { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java index ef0bc44788..13c5724c4d 100755 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java @@ -323,7 +323,7 @@ class MetadataContext { if ( value instanceof Component ) { final Component component = (Component) value; if ( component.getPropertySpan() > 1 ) { - //FIXME we are an Hibernate embedded id (ie not type) + //FIXME we are dealing with a Hibernate embedded id (ie not type) } else { //FIXME take care of declared vs non declared property @@ -406,7 +406,7 @@ class MetadataContext { // nothing to do... } - // todo : this does not account for @MappeSuperclass, mainly because this is not being tracked in our + // todo : this does not account for @MappedSuperclass, mainly because this is not being tracked in our // internal metamodel as populated from the annotations properly ManagedTypeDescriptor superType = managedType.getSuperType(); if ( superType != null ) { @@ -455,7 +455,7 @@ class MetadataContext { // appropriate attribute declarer in such cases and so the incoming metamodelClass most likely // does not represent the declarer in such cases. // - // As a result, in the case of embeddable classes we simply use getField rather than get + // As a result, in the case of embeddable classes we simply use getField rather than // getDeclaredField final boolean allowNonDeclaredFieldReference = attribute.getPersistentAttributeType() == Attribute.PersistentAttributeType.EMBEDDED @@ -478,7 +478,7 @@ class MetadataContext { } catch (IllegalArgumentException e) { // most likely a mismatch in the type we are injecting and the defined field; this represents a - // mismatch in how the annotation processor interpretted the attribute and how our metamodel + // mismatch in how the annotation processor interpreted the attribute and how our metamodel // and/or annotation binder did. // This is particularly the case as arrays are nto handled propery by the StaticMetamodel generator diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/PluralAttributeBuilder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/PluralAttributeBuilder.java index 7284263fe8..0593e23f03 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/PluralAttributeBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/PluralAttributeBuilder.java @@ -147,6 +147,6 @@ public class PluralAttributeBuilder { builder ); } - throw new UnsupportedOperationException( "Unkown collection: " + collectionClass ); + throw new UnsupportedOperationException( "Unknown collection: " + collectionClass ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index fd90f98bde..d1ba48a472 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -1066,7 +1066,7 @@ public abstract class AbstractEntityPersister } if ( columnNumbers.size() == 0 && formulaNumbers.size() == 0 ) { - // only one-to-one is lazy fetched + // only one-to-one is lazily fetched continue; } @@ -1444,8 +1444,8 @@ public abstract class AbstractEntityPersister public String[] getIdentifierAliases(String suffix) { // NOTE: this assumes something about how propertySelectFragment is implemented by the subclass! - // was toUnqotedAliasStrings( getIdentifierColumnNames() ) before - now tried - // to remove that unqoting and missing aliases.. + // was toUnquotedAliasStrings( getIdentifierColumnNames() ) before - now tried + // to remove that unquoting and missing aliases.. return new Alias( suffix ).toAliasStrings( getIdentifierAliases() ); } @@ -1456,8 +1456,8 @@ public abstract class AbstractEntityPersister public String getDiscriminatorAlias(String suffix) { // NOTE: this assumes something about how propertySelectFragment is implemented by the subclass! - // toUnqotedAliasStrings( getdiscriminatorColumnName() ) before - now tried - // to remove that unqoting and missing aliases.. + // toUnquotedAliasStrings( getDiscriminatorColumnName() ) before - now tried + // to remove that unquoting and missing aliases.. return entityMetamodel.hasSubclasses() ? new Alias( suffix ).toAliasString( getDiscriminatorAlias() ) : null; @@ -1848,7 +1848,7 @@ public abstract class AbstractEntityPersister } if ( isVersionPropertyGenerated() ) { - // the difficulty here is exactly what do we update in order to + // the difficulty here is exactly what we update in order to // force the version to be incremented in the db... throw new HibernateException( "LockMode.FORCE is currently not supported for generated version properties" ); } @@ -2337,7 +2337,7 @@ public abstract class AbstractEntityPersister // aliases for composite-id's if ( getIdentifierType().isComponentType() ) { - // Fetch embedded identifiers propertynames from the "virtual" identifier component + // Fetch embedded identifiers property names from the "virtual" identifier component CompositeType componentId = (CompositeType) getIdentifierType(); String[] idPropertyNames = componentId.getPropertyNames(); String[] idAliases = getIdentifierAliases(); @@ -2366,7 +2366,7 @@ public abstract class AbstractEntityPersister ); } else { - // embedded composite ids ( alias.idname1, alias.idname2 ) + // embedded composite ids ( alias.idName1, alias.idName2 ) subclassPropertyAliases.put( idPropertyNames[i], new String[] {idAliases[i]} ); subclassPropertyColumnNames.put( idPropertyNames[i], new String[] {idColumnNames[i]} ); } @@ -2660,7 +2660,7 @@ public abstract class AbstractEntityPersister } } - // select the correct row by either pk or rowid + // select the correct row by either pk or row id if ( useRowId ) { update.addPrimaryKeyColumns( new String[] {rowIdName} ); //TODO: eventually, rowIdName[j] } @@ -3049,7 +3049,7 @@ public abstract class AbstractEntityPersister // should be using the entity root table as the driving table; // another option here would be to choose some non-optional joined // table to use as the driving table. In all likelihood, just using - // the root table is much simplier + // the root table is much simpler // 2) Need to add the FK columns corresponding to each joined table // to the generated select list; these would then be used when // iterating the result set to determine whether all non-optional @@ -4180,7 +4180,7 @@ public abstract class AbstractEntityPersister final String drivingAlias = generateTableAlias( getRootAlias(), drivingTable - ); //we *could* regerate this inside each called method! + ); //we *could* regenerate this inside each called method! final String where = createWhereByKey( drivingTable, drivingAlias ); final String from = createFrom( drivingTable, drivingAlias ); @@ -4517,7 +4517,7 @@ public abstract class AbstractEntityPersister protected UniqueEntityLoader getAppropriateLoader(LockOptions lockOptions, SharedSessionContractImplementor session) { if ( queryLoader != null ) { - // if the user specified a custom query loader we need to that + // if the user specified a custom query loader we need to use that // regardless of any other consideration return queryLoader; } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java index f7dbfd1696..be9bfb8dbb 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java @@ -174,7 +174,7 @@ public abstract class AbstractPropertyMapping implements PropertyMapping { logDuplicateRegistration( path, existingType, type ); } else if ( !( existingType instanceof AssociationType ) ) { - // Workaround for org.hibernate.cfg.annotations.PropertyBinder.bind() adding a component for *ToOne ids + // Workaround for org.hibernate.cfg.annotations.PropertyBinder#bind() adding a component for *ToOne ids logDuplicateRegistration( path, existingType, type ); } else { @@ -215,7 +215,7 @@ public abstract class AbstractPropertyMapping implements PropertyMapping { duplicateIncompatiblePaths.add( path ); typesByPropertyPath.remove( path ); // Set everything to empty to signal action has to be taken! - // org.hibernate.hql.internal.ast.tree.DotNode.dereferenceEntityJoin() is reacting to this + // org.hibernate.hql.internal.ast.tree.DotNode#dereferenceEntityJoin() is reacting to this String[] empty = new String[0]; columnsByPropertyPath.put( path, empty ); columnReadersByPropertyPath.put( path, empty ); @@ -319,7 +319,7 @@ public abstract class AbstractPropertyMapping implements PropertyMapping { // referenced property in the mapping file (ok?) columns = columnsByPropertyPath.get( foreignKeyProperty ); if ( columns == null ) { - return; //get em on the second pass! + return; //get 'em on the second pass! } columnReaders = columnReadersByPropertyPath.get( foreignKeyProperty ); columnReaderTemplates = columnReaderTemplatesByPropertyPath.get( foreignKeyProperty ); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java index 5112857986..3f9127c7c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/UnionSubclassEntityPersister.java @@ -154,7 +154,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister { } //SPACES - //TODO: i'm not sure, but perhaps we should exclude + //TODO: I'm not sure, but perhaps we should exclude // abstract denormalized tables? int spacesSize = 1 + persistentClass.getSynchronizedTables().size(); @@ -263,7 +263,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister { getSubclassFormulaAliasClosure(), getSubclassFormulaLazyiness() ); - //TODO: include the rowids!!!! + //TODO: include the row ids!!!! if ( hasSubclasses() ) { if ( isDiscriminatorFormula() ) { select.addColumn( getDiscriminatorFormula(), getDiscriminatorAlias() ); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/walking/internal/CompositionSingularSubAttributesHelper.java b/hibernate-core/src/main/java/org/hibernate/persister/walking/internal/CompositionSingularSubAttributesHelper.java index 3ca5bf195d..62b7453760 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/walking/internal/CompositionSingularSubAttributesHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/walking/internal/CompositionSingularSubAttributesHelper.java @@ -171,7 +171,7 @@ public final class CompositionSingularSubAttributesHelper { "Cannot build AnyMappingDefinition from non-any-typed attribute" ); } - // todo : not sure how lazy is propogated into the component for a subattribute of type any + // todo : not sure how lazy is propagated into the component for a sub-attribute of type any return new StandardAnyTypeDefinition( (AnyType) aType, false ); } diff --git a/hibernate-core/src/main/java/org/hibernate/pretty/MessageHelper.java b/hibernate-core/src/main/java/org/hibernate/pretty/MessageHelper.java index 8a16c1c4a0..1535022f98 100644 --- a/hibernate-core/src/main/java/org/hibernate/pretty/MessageHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/pretty/MessageHelper.java @@ -347,7 +347,7 @@ public final class MessageHelper { SessionFactoryImplementor factory, StringBuilder s ) { // Need to use the identifier type of the collection owner - // since the incoming is value is actually the owner's id. + // since the incoming value is actually the owner's id. // Using the collection's key type causes problems with // property-ref keys. // Also need to check that the expected identifier type matches diff --git a/hibernate-core/src/main/java/org/hibernate/property/access/spi/EnhancedSetterImpl.java b/hibernate-core/src/main/java/org/hibernate/property/access/spi/EnhancedSetterImpl.java index de93fa10f6..27dbb9efe3 100644 --- a/hibernate-core/src/main/java/org/hibernate/property/access/spi/EnhancedSetterImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/property/access/spi/EnhancedSetterImpl.java @@ -45,7 +45,7 @@ public class EnhancedSetterImpl extends SetterFieldImpl { ( (CompositeTracker) value ).$$_hibernate_setOwner( propertyName, (CompositeOwner) target ); } - // This marks the attribute as initialized, so it doesn't get lazy loaded afterwards + // This marks the attribute as initialized, so it doesn't get lazily loaded afterwards if ( target instanceof PersistentAttributeInterceptable ) { PersistentAttributeInterceptor interceptor = ( (PersistentAttributeInterceptable) target ).$$_hibernate_getInterceptor(); if ( interceptor instanceof BytecodeLazyAttributeInterceptor ) { diff --git a/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java b/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java index 29a2ef2a89..2e7de16b14 100644 --- a/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java @@ -188,7 +188,7 @@ public abstract class AbstractLazyInitializer implements LazyInitializer { protected void permissiveInitialization() { if ( session == null ) { - //we have a detached collection thats set to null, reattach + //we have a detached collection that is set to null, reattach if ( sessionFactoryUuid == null ) { throw new LazyInitializationException( "could not initialize proxy [" + entityName + "#" + id + "] - no Session" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/CriteriaQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/CriteriaQueryImpl.java index 33054e5b89..6ec5ddd1d6 100755 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/CriteriaQueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/CriteriaQueryImpl.java @@ -174,7 +174,7 @@ public class CriteriaQueryImpl extends AbstractNode implements CriteriaQuery< @Override public CriteriaQuery where(Predicate... predicates) { - // TODO : assuming this should be a conjuntion, but the spec does not say specifically... + // TODO : assuming this should be a conjunction, but the spec does not say specifically... queryStructure.setRestriction( criteriaBuilder().and( predicates ) ); return this; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/CriteriaSubqueryImpl.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/CriteriaSubqueryImpl.java index 066f93078b..e186e3d1dd 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/CriteriaSubqueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/CriteriaSubqueryImpl.java @@ -155,7 +155,7 @@ public class CriteriaSubqueryImpl extends ExpressionImpl implements Subque @Override public Subquery where(Predicate... predicates) { - // TODO : assuming this should be a conjuntion, but the spec does not say specifically... + // TODO : assuming this should be a conjunction, but the spec does not say specifically... queryStructure.setRestriction( criteriaBuilder().and( predicates ) ); return this; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/expression/EntityTypeExpression.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/expression/EntityTypeExpression.java index dca77f0bbd..69b6ae768b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/expression/EntityTypeExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/expression/EntityTypeExpression.java @@ -23,7 +23,7 @@ public class EntityTypeExpression extends ExpressionImpl implements Serial } public void registerParameters(ParameterRegistry registry) { - // nothign to do + // nothing to do } public String render(RenderingContext renderingContext) { diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/path/PluralAttributePath.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/path/PluralAttributePath.java index 7b0fc3e332..401a3fc504 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/path/PluralAttributePath.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/path/PluralAttributePath.java @@ -52,9 +52,9 @@ public class PluralAttributePath extends AbstractPathImpl implements Seria return attribute.getDeclaringType().getJavaType().getName() + '.' + attribute.getName(); } case MAPPED_SUPERCLASS: { - // the attribute is declared in a mappedsuperclass + // the attribute is declared in a mappedSuperclass if ( getPathSource().getModel().getBindableType() == Bindable.BindableType.ENTITY_TYPE ) { - // the role will be assigned to the "nearest" EnityType subclass of the MappedSuperclassType + // the role will be assigned to the "nearest" EntityType subclass of the MappedSuperclassType final EntityType entityTypeNearestDeclaringType = locateNearestSubclassEntity( (MappedSuperclassType) attribute.getDeclaringType(), (EntityType) getPathSource().getModel() @@ -89,7 +89,7 @@ public class PluralAttributePath extends AbstractPathImpl implements Seria entityType = (EntityType) singularAttribute.getDeclaringType(); } else if ( singularAttribute.getDeclaringType().getPersistenceType() == Type.PersistenceType.MAPPED_SUPERCLASS ){ - // find the "nearest" EnityType subclass of the MappedSuperclassType + // find the "nearest" EntityType subclass of the MappedSuperclassType entityType = locateNearestSubclassEntity( (MappedSuperclassType) singularAttribute.getDeclaringType(), (EntityType) parentPath.getModel() diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/path/SingularAttributePath.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/path/SingularAttributePath.java index cb228b0b45..04f4fdf92b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/path/SingularAttributePath.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/path/SingularAttributePath.java @@ -69,7 +69,7 @@ public class SingularAttributePath extends AbstractPathImpl implements Ser @Override protected Attribute locateAttributeInternal(String attributeName) { final Attribute attribute = managedType.getAttribute( attributeName ); - // ManagedType.locateAttribute should throw exception rather than return + // ManagedType#locateAttribute() should throw exception rather than return // null, but just to be safe... if ( attribute == null ) { throw new IllegalArgumentException( "Could not resolve attribute named " + attributeName ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/predicate/InPredicate.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/predicate/InPredicate.java index 9b29e5bcd8..5463943cb4 100755 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/predicate/InPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/predicate/InPredicate.java @@ -160,7 +160,7 @@ public class InPredicate final Expression exp = getExpression(); if ( ParameterExpressionImpl.class.isInstance( exp ) ) { // technically we only need to CAST (afaik) if expression and all values are parameters. - // but checking for that condition could take long time on a lon value list + // but checking for that condition could take long time on a long value list final ParameterExpressionImpl parameterExpression = (ParameterExpressionImpl) exp; final SessionFactoryImplementor sfi = criteriaBuilder().getEntityManagerFactory().unwrap( SessionFactoryImplementor.class ); final Type mappingType = sfi.getTypeResolver().heuristicType( parameterExpression.getParameterType().getName() ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java b/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java index 2c0eafd11a..b16f8256e3 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java @@ -1248,7 +1248,7 @@ public abstract class AbstractProducedQuery implements QueryImplementor { * @return {@code true} indicates they can be applied, {@code false} otherwise. */ protected boolean canApplyAliasSpecificLockModeHints() { - // only procedure/function calls cannot i believe + // only procedure/function calls cannot I believe return true; } diff --git a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/ResourceRegistryStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/ResourceRegistryStandardImpl.java index 3f3af3b97f..5c31b2f014 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/ResourceRegistryStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/ResourceRegistryStandardImpl.java @@ -44,7 +44,7 @@ public final class ResourceRegistryStandardImpl implements ResourceRegistry { // Dummy value to associate with an Object in the backing Map when we use it as a set: private static final Object PRESENT = new Object(); - //Used instead of Collections.EMPTY_SET to avoid polymorhic calls on xref; + //Used instead of Collections.EMPTY_SET to avoid polymorphic calls on xref; //Also, uses an HashMap as it were an HashSet, as technically we just need the Set semantics //but in this case the overhead of HashSet is not negligible. private static final HashMap EMPTY = new HashMap( 1, 0.2f ); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ForUpdateFragment.java b/hibernate-core/src/main/java/org/hibernate/sql/ForUpdateFragment.java index df3f4554aa..aa16a7fe86 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ForUpdateFragment.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ForUpdateFragment.java @@ -101,7 +101,7 @@ public class ForUpdateFragment { } return ""; } - // TODO: pass lockmode + // TODO: pass lock mode if(isNowaitEnabled) { return dialect.getForUpdateNowaitString( aliases.toString() ); } 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 31c1d400ee..3c743ba8c2 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/Template.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/Template.java @@ -268,7 +268,7 @@ public final class Template { result.append( trimOperands.from ).append( ' ' ); } else if ( trimOperands.trimSpec != null || trimOperands.trimChar != null ) { - // I think ANSI SQL says that the 'from' is not optional if either trim-spec or trim-char are specified + // I think ANSI SQL says that the 'from' is not optional if either trim-spec or trim-char is specified result.append( "from " ); } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java index f05f9a8dce..4f4e07529e 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java @@ -436,7 +436,7 @@ public class SchemaManagementToolCoordinator { */ public static final MigrateSettingSelector INSTANCE = new MigrateSettingSelector(); - // todo : should this define new migrattor-specific settings? + // todo : should this define new migrator-specific settings? // for now we reuse the CREATE settings where applicable @Override diff --git a/hibernate-core/src/main/java/org/hibernate/transform/CacheableResultTransformer.java b/hibernate-core/src/main/java/org/hibernate/transform/CacheableResultTransformer.java index 1a1e40109f..6949f6bbb9 100644 --- a/hibernate-core/src/main/java/org/hibernate/transform/CacheableResultTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/transform/CacheableResultTransformer.java @@ -31,7 +31,7 @@ public class CacheableResultTransformer implements ResultTransformer { // array with the i-th element indicating whether the i-th // expression returned by a query is included in the tuple; - // IMPLLEMENTATION NOTE: + // IMPLEMENTATION NOTE: // "joined" and "fetched" associations may use the same SQL, // but result in different tuple and cached values. This is // because "fetched" associations are excluded from the tuple. diff --git a/hibernate-core/src/main/java/org/hibernate/transform/PassThroughResultTransformer.java b/hibernate-core/src/main/java/org/hibernate/transform/PassThroughResultTransformer.java index 077cae0931..1e5fb599cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/transform/PassThroughResultTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/transform/PassThroughResultTransformer.java @@ -42,7 +42,7 @@ public class PassThroughResultTransformer extends BasicTransformerAdapter implem /* package-protected */ List untransformToTuples(List results, boolean isSingleResult) { - // untransform only if necessary; if transformed, do it in place; + // un-transform only if necessary; if transformed, do it in place; if ( isSingleResult ) { for ( int i = 0 ; i < results.size() ; i++ ) { Object[] tuple = untransformToTuple( results.get( i ), isSingleResult); diff --git a/hibernate-core/src/main/java/org/hibernate/transform/Transformers.java b/hibernate-core/src/main/java/org/hibernate/transform/Transformers.java index a5b569458c..e99b814fbd 100644 --- a/hibernate-core/src/main/java/org/hibernate/transform/Transformers.java +++ b/hibernate-core/src/main/java/org/hibernate/transform/Transformers.java @@ -23,7 +23,7 @@ final public class Transformers { public static final ToListResultTransformer TO_LIST = ToListResultTransformer.INSTANCE; /** - * Creates a resulttransformer that will inject aliased values into + * Creates a ResultTransformer that will inject aliased values into * instances of Class via property methods or fields. */ public static ResultTransformer aliasToBean(Class target) { diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java index a3ecaa3f93..903a88fb62 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java @@ -248,7 +248,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { @Override public void setIdentifier(Object entity, Serializable id) throws HibernateException { - // 99% of the time the session is not needed. Its only needed for certain brain-dead + // 99% of the time the session is not needed. It's only needed for certain brain-dead // interpretations of JPA 2 "derived identity" support setIdentifier( entity, id, null ); } @@ -506,7 +506,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { @Override public void resetIdentifier(Object entity, Serializable currentId, Object currentVersion) { - // 99% of the time the session is not needed. Its only needed for certain brain-dead + // 99% of the time the session is not needed. It's only needed for certain brain-dead // interpretations of JPA 2 "derived identity" support resetIdentifier( entity, currentId, currentVersion, null ); } @@ -696,7 +696,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { @Override public final Object instantiate(Serializable id) throws HibernateException { - // 99% of the time the session is not needed. Its only needed for certain brain-dead + // 99% of the time the session is not needed. It's only needed for certain brain-dead // interpretations of JPA 2 "derived identity" support return instantiate( id, null ); } diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/BytecodeEnhancementMetadataPojoImpl.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/BytecodeEnhancementMetadataPojoImpl.java index 1496c2cbed..de07cc6990 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/BytecodeEnhancementMetadataPojoImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/BytecodeEnhancementMetadataPojoImpl.java @@ -145,7 +145,7 @@ public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhanc final PersistentAttributeInterceptable entity = (PersistentAttributeInterceptable) entityTuplizer .instantiate( identifier, session ); - // clear the fields that are marked as dirty in the dirtyness tracker + // clear the fields that are marked as dirty in the dirtiness tracker if ( entity instanceof SelfDirtinessTracker ) { ( (SelfDirtinessTracker) entity ).$$_hibernate_clearDirtyAttributes(); } diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java index 623c95d781..ef6aaf97a1 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java @@ -223,7 +223,7 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { } } - // clear the fields that are marked as dirty in the dirtyness tracker + // clear the fields that are marked as dirty in the dirtiness tracker if ( entity instanceof SelfDirtinessTracker ) { ( (SelfDirtinessTracker) entity ).$$_hibernate_clearDirtyAttributes(); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java index e931ac1eb9..18d3bdd342 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java @@ -356,7 +356,7 @@ public abstract class CollectionType extends AbstractType implements Association public boolean isDirty(Object old, Object current, SharedSessionContractImplementor session) throws HibernateException { - // collections don't dirty an unversioned parent entity + // collections don't dirty an un-versioned parent entity // TODO: I don't really like this implementation; it would be better if // this was handled by searchForDirtyCollections() diff --git a/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java b/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java index 3e5cee8d65..feb669ed55 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/ComponentType.java @@ -115,7 +115,7 @@ public class ComponentType extends AbstractType implements CompositeType, Proced @Override public int[] sqlTypes(Mapping mapping) throws MappingException { - //Not called at runtime so doesn't matter if its slow :) + //Not called at runtime so doesn't matter if it's slow :) int[] sqlTypes = new int[getColumnSpan( mapping )]; int n = 0; for ( int i = 0; i < propertySpan; i++ ) { @@ -129,7 +129,7 @@ public class ComponentType extends AbstractType implements CompositeType, Proced @Override public Size[] dictatedSizes(Mapping mapping) throws MappingException { - //Not called at runtime so doesn't matter if its slow :) + //Not called at runtime so doesn't matter if it's slow :) final Size[] sizes = new Size[getColumnSpan( mapping )]; int soFar = 0; for ( Type propertyType : propertyTypes ) { @@ -142,7 +142,7 @@ public class ComponentType extends AbstractType implements CompositeType, Proced @Override public Size[] defaultSizes(Mapping mapping) throws MappingException { - //Not called at runtime so doesn't matter if its slow :) + //Not called at runtime so doesn't matter if it's slow :) final Size[] sizes = new Size[getColumnSpan( mapping )]; int soFar = 0; for ( Type propertyType : propertyTypes ) { @@ -690,7 +690,7 @@ public class ComponentType extends AbstractType implements CompositeType, Proced if ( value != null ) { Object result = instantiate( owner, session ); Object[] values = (Object[]) value; - Object[] resolvedValues = new Object[values.length]; //only really need new array during semiresolve! + Object[] resolvedValues = new Object[values.length]; //only really need new array during semi-resolve! for ( int i = 0; i < values.length; i++ ) { resolvedValues[i] = propertyTypes[i].resolve( values[i], session, owner ); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/CompositeCustomType.java b/hibernate-core/src/main/java/org/hibernate/type/CompositeCustomType.java index 5ab326ce62..462b92a99c 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CompositeCustomType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CompositeCustomType.java @@ -250,7 +250,7 @@ public class CompositeCustomType extends AbstractType implements CompositeType, @Override public Size[] dictatedSizes(Mapping mapping) throws MappingException { - //Not called at runtime so doesn't matter if its slow :) + //Not called at runtime so doesn't matter if it's slow :) final Size[] sizes = new Size[getColumnSpan( mapping )]; int soFar = 0; for ( Type propertyType : userType.getPropertyTypes() ) { @@ -263,7 +263,7 @@ public class CompositeCustomType extends AbstractType implements CompositeType, @Override public Size[] defaultSizes(Mapping mapping) throws MappingException { - //Not called at runtime so doesn't matter if its slow :) + //Not called at runtime so doesn't matter if it's slow :) final Size[] sizes = new Size[getColumnSpan( mapping )]; int soFar = 0; for ( Type propertyType : userType.getPropertyTypes() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/type/EntityType.java b/hibernate-core/src/main/java/org/hibernate/type/EntityType.java index 11ca22ff7f..a1271c1acd 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/EntityType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/EntityType.java @@ -518,7 +518,7 @@ public abstract class EntityType extends AbstractType implements AssociationType Object propertyValue = entityPersister.getPropertyValue( value, uniqueKeyPropertyName ); // We now have the value of the property-ref we reference. However, // we need to dig a little deeper, as that property might also be - // an entity type, in which case we need to resolve its identitifier + // an entity type, in which case we need to resolve its identifier Type type = entityPersister.getPropertyType( uniqueKeyPropertyName ); if ( type.isEntityType() ) { propertyValue = ( (EntityType) type ).getIdentifier( propertyValue, session ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/ManyToOneType.java b/hibernate-core/src/main/java/org/hibernate/type/ManyToOneType.java index a461bfe5c3..c6be39af5e 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/ManyToOneType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/ManyToOneType.java @@ -120,7 +120,7 @@ public class ManyToOneType extends EntityType { @Override public boolean isAlwaysDirtyChecked() { - // always need to dirty-check, even when non-updateable; + // always need to dirty-check, even when non-updatable; // this ensures that when the association is updated, // the entity containing this association will be updated // in the cache diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ArrayMutabilityPlan.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ArrayMutabilityPlan.java index 9bd6c61ab9..49bc40f2d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ArrayMutabilityPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ArrayMutabilityPlan.java @@ -19,7 +19,7 @@ public class ArrayMutabilityPlan extends MutableMutabilityPlan { @SuppressWarnings({ "unchecked", "SuspiciousSystemArraycopy" }) public T deepCopyNotNull(T value) { if ( ! value.getClass().isArray() ) { - // ugh! cannot find a way to properly define the type signature here to + // ugh! cannot find a way to properly define the type signature here throw new IllegalArgumentException( "Value was not an array [" + value.getClass().getName() + "]" ); } final int length = Array.getLength( value ); From 6fb52c4fcdb4860cb374a5dd6ab1dc099047dbc3 Mon Sep 17 00:00:00 2001 From: Yanming Zhou Date: Fri, 18 Sep 2020 10:59:28 +0800 Subject: [PATCH 12/16] HHH-14219 Fix duplicated rows of sequence table if generator is shared by multiple entities --- .../hibernate/id/enhanced/TableStructure.java | 24 +++--- .../org/hibernate/id/enhanced/HHH14219.java | 86 +++++++++++++++++++ 2 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/id/enhanced/HHH14219.java diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java index 1907835368..5a2d5420df 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java @@ -249,8 +249,10 @@ public class TableStructure implements DatabaseStructure { ); Table table = namespace.locateTable( logicalQualifiedTableName.getObjectName() ); + boolean tableCreated = false; if ( table == null ) { table = namespace.createTable( logicalQualifiedTableName.getObjectName(), false ); + tableCreated = true; } this.tableNameText = jdbcEnvironment.getQualifiedObjectNameFormatter().format( @@ -268,17 +270,19 @@ public class TableStructure implements DatabaseStructure { this.updateQuery = "update " + tableNameText + " set " + valueColumnNameText + "= ?" + " where " + valueColumnNameText + "=?"; + if ( tableCreated ) { + ExportableColumn valueColumn = new ExportableColumn( + database, + table, + valueColumnNameText, + LongType.INSTANCE + ); - ExportableColumn valueColumn = new ExportableColumn( - database, - table, - valueColumnNameText, - LongType.INSTANCE - ); - table.addColumn( valueColumn ); + table.addColumn( valueColumn ); - table.addInitCommand( - new InitCommand( "insert into " + tableNameText + " values ( " + initialValue + " )" ) - ); + table.addInitCommand( + new InitCommand( "insert into " + tableNameText + " values ( " + initialValue + " )" ) + ); + } } } diff --git a/hibernate-core/src/test/java/org/hibernate/id/enhanced/HHH14219.java b/hibernate-core/src/test/java/org/hibernate/id/enhanced/HHH14219.java new file mode 100644 index 0000000000..5f0c7e3118 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/id/enhanced/HHH14219.java @@ -0,0 +1,86 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.id.enhanced; + +import static org.junit.Assert.assertEquals; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.MappedSuperclass; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.dialect.MySQLDialect; +import org.hibernate.query.Query; +import org.hibernate.testing.RequiresDialect; +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.CustomRunner; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * {@inheritDoc} + * + * @author Yanming Zhou + */ +@TestForIssue(jiraKey = "HHH-14219") +@RunWith(CustomRunner.class) +@RequiresDialect(MySQLDialect.class) +public class HHH14219 { + + private SessionFactory sf; + + @Before + public void setup() { + StandardServiceRegistryBuilder srb = new StandardServiceRegistryBuilder() + + .applySetting("hibernate.show_sql", "true").applySetting("hibernate.format_sql", "true") + .applySetting("hibernate.hbm2ddl.auto", "create-drop"); + + Metadata metadata = new MetadataSources(srb.build()).addAnnotatedClass(BaseEntity.class) + .addAnnotatedClass(Foo.class).addAnnotatedClass(Bar.class).buildMetadata(); + + sf = metadata.buildSessionFactory(); + } + + @Test + public void testSequenceTableContainsOnlyOneRow() throws Exception { + try (Session session = sf.openSession()) { + @SuppressWarnings("unchecked") + Query q = session.createNativeQuery("select count(*) from " + BaseEntity.SHARED_SEQ_NAME); + assertEquals(1, q.uniqueResult().intValue()); + } + } + + @MappedSuperclass + public static class BaseEntity { + + public static final String SHARED_SEQ_NAME = "shared_seq"; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO, generator = SHARED_SEQ_NAME) + protected Long id; + + } + + @Entity + public static class Foo extends BaseEntity { + + } + + @Entity + public static class Bar extends BaseEntity { + + } + +} From 4c5f94f917bad9f83009ade145a2b80aae6fc09f Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Sun, 13 Sep 2020 09:19:54 -0400 Subject: [PATCH 13/16] HHH-14212 revert back HHH-14124 (retaining testing case) --- .../java/org/hibernate/loader/Loader.java | 109 ++++++------------ .../test/graphs/LoadAndFetchGraphTest.java | 5 +- 2 files changed, 40 insertions(+), 74 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java index ca27b446ad..43239a3b7d 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java @@ -68,7 +68,6 @@ import org.hibernate.event.spi.EventType; import org.hibernate.event.spi.PostLoadEvent; import org.hibernate.event.spi.PreLoadEvent; import org.hibernate.event.spi.PreLoadEventListener; -import org.hibernate.graph.spi.GraphImplementor; import org.hibernate.hql.internal.HolderInstantiator; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; @@ -381,8 +380,8 @@ public abstract class Loader { final boolean returnProxies) throws HibernateException { final int entitySpan = getEntityPersisters().length; - final List hydratedObjects = entitySpan == 0 ? - null : new ArrayList<>( entitySpan ); + final List hydratedObjects = entitySpan == 0 ? + null : new ArrayList( entitySpan ); final Object result; try { @@ -423,8 +422,8 @@ public abstract class Loader { final EntityKey keyToRead) throws HibernateException { final int entitySpan = getEntityPersisters().length; - final List nullSeparatedHydratedObjects = entitySpan == 0 ? - null : new ArrayList<>( entitySpan ); + final List hydratedObjects = entitySpan == 0 ? + null : new ArrayList( entitySpan ); Object result = null; final EntityKey[] loadedKeys = new EntityKey[entitySpan]; @@ -437,14 +436,10 @@ public abstract class Loader { queryParameters, getLockModes( queryParameters.getLockOptions() ), null, - nullSeparatedHydratedObjects, + hydratedObjects, loadedKeys, returnProxies ); - if ( nullSeparatedHydratedObjects != null ) { - // Signal that a new row starts. Used in initializeEntitiesAndCollections - nullSeparatedHydratedObjects.add( null ); - } if ( !keyToRead.equals( loadedKeys[0] ) ) { throw new AssertionFailure( String.format( @@ -470,7 +465,7 @@ public abstract class Loader { } initializeEntitiesAndCollections( - nullSeparatedHydratedObjects, + hydratedObjects, resultSet, session, queryParameters.isReadOnly( session ) @@ -701,7 +696,7 @@ public abstract class Loader { final QueryParameters queryParameters, final LockMode[] lockModesArray, final EntityKey optionalObjectKey, - final List hydratedObjects, + final List hydratedObjects, final EntityKey[] keys, boolean returnProxies) throws SQLException, HibernateException { return getRowFromResultSet( @@ -723,7 +718,7 @@ public abstract class Loader { final QueryParameters queryParameters, final LockMode[] lockModesArray, final EntityKey optionalObjectKey, - final List hydratedObjects, + final List hydratedObjects, final EntityKey[] keys, boolean returnProxies, ResultTransformer forcedResultTransformer) throws SQLException, HibernateException { @@ -787,7 +782,7 @@ public abstract class Loader { SharedSessionContractImplementor session, EntityKey[] keys, LockMode[] lockModes, - List hydratedObjects) throws SQLException { + List hydratedObjects) throws SQLException { final int entitySpan = persisters.length; final int numberOfPersistersToProcess; @@ -990,7 +985,7 @@ public abstract class Loader { final int entitySpan = getEntityPersisters().length; final boolean createSubselects = isSubselectLoadingEnabled(); final List subselectResultKeys = createSubselects ? new ArrayList<>() : null; - final List nullSeparatedHydratedObjectsPerRow = entitySpan == 0 ? null : new ArrayList<>(); + final List hydratedObjects = entitySpan == 0 ? null : new ArrayList<>( entitySpan * 10 ); final List results = getRowsFromResultSet( rs, @@ -999,12 +994,12 @@ public abstract class Loader { returnProxies, forcedResultTransformer, maxRows, - nullSeparatedHydratedObjectsPerRow, + hydratedObjects, subselectResultKeys ); initializeEntitiesAndCollections( - nullSeparatedHydratedObjectsPerRow, + hydratedObjects, rs, session, queryParameters.isReadOnly( session ), @@ -1023,7 +1018,7 @@ public abstract class Loader { boolean returnProxies, ResultTransformer forcedResultTransformer, int maxRows, - List nullSeparatedHydratedObjects, + List hydratedObjects, List subselectResultKeys) throws SQLException { final int entitySpan = getEntityPersisters().length; final boolean createSubselects = isSubselectLoadingEnabled(); @@ -1047,16 +1042,12 @@ public abstract class Loader { queryParameters, lockModesArray, optionalObjectKey, - nullSeparatedHydratedObjects, + hydratedObjects, keys, returnProxies, forcedResultTransformer ); results.add( result ); - if ( nullSeparatedHydratedObjects != null ) { - // Signal that a new row starts. Used in initializeEntitiesAndCollections - nullSeparatedHydratedObjects.add( null ); - } if ( createSubselects ) { subselectResultKeys.add( keys ); keys = new EntityKey[entitySpan]; //can't reuse in this case @@ -1147,12 +1138,12 @@ public abstract class Loader { } private void initializeEntitiesAndCollections( - final List nullSeparatedHydratedObjects, + final List hydratedObjects, final Object resultSetId, final SharedSessionContractImplementor session, final boolean readOnly) throws HibernateException { initializeEntitiesAndCollections( - nullSeparatedHydratedObjects, + hydratedObjects, resultSetId, session, readOnly, @@ -1161,7 +1152,7 @@ public abstract class Loader { } private void initializeEntitiesAndCollections( - final List nullSeparatedHydratedObjects, + final List hydratedObjects, final Object resultSetId, final SharedSessionContractImplementor session, final boolean readOnly, @@ -1193,40 +1184,22 @@ public abstract class Loader { post = null; } - if ( nullSeparatedHydratedObjects != null && !nullSeparatedHydratedObjects.isEmpty() ) { - if ( LOG.isTraceEnabled() ) { - int hydratedObjectsSize = 0; - for ( Object hydratedObject : nullSeparatedHydratedObjects ) { - if ( hydratedObject != null ) { - ++hydratedObjectsSize; - } - } - LOG.tracev( "Total objects hydrated: {0}", hydratedObjectsSize ); - } + if ( hydratedObjects != null ) { + int hydratedObjectsSize = hydratedObjects.size(); + LOG.tracev( "Total objects hydrated: {0}", hydratedObjectsSize ); - final Iterable listeners = session - .getFactory() - .getServiceRegistry() - .getService( EventListenerRegistry.class ) - .getEventListenerGroup( EventType.PRE_LOAD ) - .listeners(); + if ( hydratedObjectsSize != 0 ) { + final Iterable listeners = session + .getFactory() + .getServiceRegistry() + .getService( EventListenerRegistry.class ) + .getEventListenerGroup( EventType.PRE_LOAD ) + .listeners(); - GraphImplementor fetchGraphLoadContextToRestore = session.getFetchGraphLoadContext(); - for ( Object hydratedObject : nullSeparatedHydratedObjects ) { - if ( hydratedObject == null ) { - // This is a hack to signal that we're starting to process a new row - - // HHH-14124: TwoPhaseLoad has nasty side-effects in order to handle sub-graphs. - // That's very fragile, but someone would need to spend much more time on this - // in order to implement it correctly, and apparently that's already been done in ORM 6.0. - // So for now, we'll just ensure side-effects (and whatever bugs they lead to) - // are limited to each row. - session.setFetchGraphLoadContext( fetchGraphLoadContextToRestore ); - - continue; + for ( Object hydratedObject : hydratedObjects ) { + TwoPhaseLoad.initializeEntity( hydratedObject, readOnly, session, pre, listeners ); } - TwoPhaseLoad.initializeEntity( hydratedObject, readOnly, session, pre, listeners ); } } @@ -1242,13 +1215,8 @@ public abstract class Loader { } } - if ( nullSeparatedHydratedObjects != null ) { - for ( Object hydratedObject : nullSeparatedHydratedObjects ) { - if ( hydratedObject == null ) { - // This is a hack to signal that we're starting to process a new row - // Ignore - continue; - } + if ( hydratedObjects != null ) { + for ( Object hydratedObject : hydratedObjects ) { TwoPhaseLoad.afterInitialize( hydratedObject, session ); } } @@ -1258,13 +1226,8 @@ public abstract class Loader { // endCollectionLoad to ensure the collection is in the // persistence context. final PersistenceContext persistenceContext = session.getPersistenceContextInternal(); - if ( nullSeparatedHydratedObjects != null && !nullSeparatedHydratedObjects.isEmpty() ) { - for ( Object hydratedObject : nullSeparatedHydratedObjects ) { - if ( hydratedObject == null ) { - // This is a hack to signal that we're starting to process a new row - // Ignore - continue; - } + if ( hydratedObjects != null && hydratedObjects.size() > 0 ) { + for ( Object hydratedObject : hydratedObjects ) { TwoPhaseLoad.postLoad( hydratedObject, session, post ); if ( afterLoadActions != null ) { for ( AfterLoadAction afterLoadAction : afterLoadActions ) { @@ -1622,7 +1585,7 @@ public abstract class Loader { final Object optionalObject, final EntityKey optionalObjectKey, final LockMode[] lockModes, - final List hydratedObjects, + final List hydratedObjects, final SharedSessionContractImplementor session) throws HibernateException, SQLException { final int cols = persisters.length; final EntityAliases[] entityAliases = getEntityAliases(); @@ -1689,7 +1652,7 @@ public abstract class Loader { final EntityKey key, final Object object, final LockMode requestedLockMode, - List hydratedObjects, + List hydratedObjects, final SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( !persister.isInstance( object ) ) { @@ -1757,7 +1720,7 @@ public abstract class Loader { final LockMode lockMode, final EntityKey optionalObjectKey, final Object optionalObject, - final List hydratedObjects, + final List hydratedObjects, final SharedSessionContractImplementor session) throws HibernateException, SQLException { final String instanceClass = getInstanceClass( diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/LoadAndFetchGraphTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/LoadAndFetchGraphTest.java index fb52b5d0c9..58deac1bf9 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/LoadAndFetchGraphTest.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/LoadAndFetchGraphTest.java @@ -42,7 +42,6 @@ import static org.junit.Assert.assertTrue; * @author Andrea Boriero * @author Nathan Xu */ -@TestForIssue(jiraKey = "HHH-14097") public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase { @Override @@ -180,6 +179,7 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase { } @Test + @TestForIssue(jiraKey = "HHH-14097") public void testQueryById() { Statistics statistics = entityManagerFactory().unwrap( SessionFactory.class ).getStatistics(); statistics.clear(); @@ -205,6 +205,7 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase { } @Test + @TestForIssue(jiraKey = "HHH-14097") public void testQueryByIdWithLoadGraph() { Statistics statistics = entityManagerFactory().unwrap( SessionFactory.class ).getStatistics(); statistics.clear(); @@ -241,6 +242,7 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase { } @Test + @TestForIssue(jiraKey = "HHH-14097") public void testQueryByIdWithFetchGraph() { Statistics statistics = entityManagerFactory().unwrap( SessionFactory.class ).getStatistics(); statistics.clear(); @@ -275,6 +277,7 @@ public class LoadAndFetchGraphTest extends BaseEntityManagerFunctionalTestCase { } @Test + @TestForIssue(jiraKey = "HHH-14097") public void testQueryByIdWithFetchGraph2() { Statistics statistics = entityManagerFactory().unwrap( SessionFactory.class ).getStatistics(); statistics.clear(); From 7cfdd0609d3dd77f1e55e9dfaf0826f9becfd843 Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Sun, 13 Sep 2020 09:24:19 -0400 Subject: [PATCH 14/16] HHH-14212 revert back HHH-14097 (retaining testing case) --- .../engine/internal/TwoPhaseLoad.java | 121 +++++++----------- 1 file changed, 46 insertions(+), 75 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java index ff84cd2c9a..92e7670de4 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java @@ -206,91 +206,62 @@ public final class TwoPhaseLoad { String entityName = persister.getEntityName(); String[] propertyNames = persister.getPropertyNames(); final Type[] types = persister.getPropertyTypes(); + + final GraphImplementor fetchGraphContext = session.getFetchGraphLoadContext(); + + for ( int i = 0; i < hydratedState.length; i++ ) { + final Object value = hydratedState[i]; + if ( debugEnabled ) { + LOG.debugf( + "Processing attribute `%s` : value = %s", + propertyNames[i], + value == LazyPropertyInitializer.UNFETCHED_PROPERTY ? "" : value == PropertyAccessStrategyBackRefImpl.UNKNOWN ? "" : value + ); + } - GraphImplementor fetchGraphContext = session.getFetchGraphLoadContext(); - if ( fetchGraphContext != null && !fetchGraphContext.appliesTo( entity.getClass() ) ) { - LOG.warnf( "Entity graph specified is not applicable to the entity [%s]. Ignored.", entity); - fetchGraphContext = null; - session.setFetchGraphLoadContext( null ); - } - - try { - for ( int i = 0; i < hydratedState.length; i++ ) { - final Object value = hydratedState[i]; + if ( value == LazyPropertyInitializer.UNFETCHED_PROPERTY ) { if ( debugEnabled ) { - LOG.debugf( - "Processing attribute `%s` : value = %s", - propertyNames[i], - value == LazyPropertyInitializer.UNFETCHED_PROPERTY ? - "" : - value == PropertyAccessStrategyBackRefImpl.UNKNOWN ? "" : value - ); + LOG.debugf( "Resolving attribute : `%s`", propertyNames[i] ); } - if ( value == LazyPropertyInitializer.UNFETCHED_PROPERTY ) { - if ( debugEnabled ) { - LOG.debugf( "Resolving attribute : `%s`", propertyNames[i] ); - } - - // IMPLEMENTATION NOTE: This is a lazy property on a bytecode-enhanced entity. - // hydratedState[i] needs to remain LazyPropertyInitializer.UNFETCHED_PROPERTY so that - // setPropertyValues() below (ultimately AbstractEntityTuplizer#setPropertyValues) works properly - // No resolution is necessary, unless the lazy property is a collection. - if ( types[i].isCollectionType() ) { - // IMPLEMENTATION NOTE: this is a lazy collection property on a bytecode-enhanced entity. - // HHH-10989: We need to resolve the collection so that a CollectionReference is added to StatefulPersistentContext. - // As mentioned above, hydratedState[i] needs to remain LazyPropertyInitializer.UNFETCHED_PROPERTY - // so do not assign the resolved, uninitialized PersistentCollection back to hydratedState[i]. - Boolean overridingEager = getOverridingEager( - session, - entityName, - propertyNames[i], - types[i], - debugEnabled - ); - types[i].resolve( value, session, entity, overridingEager ); - } + // IMPLEMENTATION NOTE: This is a lazy property on a bytecode-enhanced entity. + // hydratedState[i] needs to remain LazyPropertyInitializer.UNFETCHED_PROPERTY so that + // setPropertyValues() below (ultimately AbstractEntityTuplizer#setPropertyValues) works properly + // No resolution is necessary, unless the lazy property is a collection. + if ( types[i].isCollectionType() ) { + // IMPLEMENTATION NOTE: this is a lazy collection property on a bytecode-enhanced entity. + // HHH-10989: We need to resolve the collection so that a CollectionReference is added to StatefulPersistentContext. + // As mentioned above, hydratedState[i] needs to remain LazyPropertyInitializer.UNFETCHED_PROPERTY + // so do not assign the resolved, uninitialized PersistentCollection back to hydratedState[i]. + Boolean overridingEager = getOverridingEager( session, entityName, propertyNames[i], types[i], debugEnabled ); + types[i].resolve( value, session, entity, overridingEager ); } - else if ( value != PropertyAccessStrategyBackRefImpl.UNKNOWN ) { - if ( debugEnabled ) { - final boolean isLazyEnhanced = persister.getBytecodeEnhancementMetadata() - .getLazyAttributesMetadata() - .getLazyAttributeNames() - .contains( propertyNames[i] ); - LOG.debugf( - "Attribute (`%s`) - enhanced for lazy-loading? - %s", - propertyNames[i], - isLazyEnhanced - ); - } - - // we know value != LazyPropertyInitializer.UNFETCHED_PROPERTY - Boolean overridingEager = getOverridingEager( - session, - entityName, - propertyNames[i], - types[i], - debugEnabled - ); - hydratedState[i] = types[i].isEntityType() - ? entityResolver.resolve( (EntityType) types[i], value, session, entity, overridingEager ) - : types[i].resolve( value, session, entity, overridingEager ); - } - else { - if ( debugEnabled ) { - LOG.debugf( "Skipping attribute : `%s`", propertyNames[i] ); - } + } + else if ( value != PropertyAccessStrategyBackRefImpl.UNKNOWN ) { + if ( debugEnabled ) { + final boolean isLazyEnhanced = persister.getBytecodeEnhancementMetadata() + .getLazyAttributesMetadata() + .getLazyAttributeNames() + .contains( propertyNames[i] ); + LOG.debugf( "Attribute (`%s`) - enhanced for lazy-loading? - %s", propertyNames[i], isLazyEnhanced ); } + // we know value != LazyPropertyInitializer.UNFETCHED_PROPERTY + Boolean overridingEager = getOverridingEager( session, entityName, propertyNames[i], types[i], debugEnabled ); + hydratedState[i] = types[i].isEntityType() + ? entityResolver.resolve( (EntityType) types[i], value, session, entity, overridingEager ) + : types[i].resolve( value, session, entity, overridingEager ); + } + else { + if ( debugEnabled ) { + LOG.debugf( "Skipping attribute : `%s`", propertyNames[i] ); + } + } + + if ( session.getFetchGraphLoadContext() != fetchGraphContext ) { session.setFetchGraphLoadContext( fetchGraphContext ); } } - finally { - // HHH-14097 - // Fetch entity graph should be applied only once on top level (for root hydrated object) - // e.g., see org.hibernate.loader.Loader for details - session.setFetchGraphLoadContext( null ); - } } public static void initializeEntityFromEntityEntryLoadedState( From 39b42c0a6ab720ae8dbb95535fa5dd28946d0a86 Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Sun, 13 Sep 2020 09:34:59 -0400 Subject: [PATCH 15/16] HHH-14212 revert back HHH-8776 (retaining testing case) --- .../engine/internal/TwoPhaseLoad.java | 66 +------------------ .../spi/SharedSessionContractImplementor.java | 28 -------- .../org/hibernate/internal/SessionImpl.java | 18 ----- .../query/internal/AbstractProducedQuery.java | 4 -- 4 files changed, 2 insertions(+), 114 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java index 92e7670de4..70956b6281 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java @@ -32,8 +32,6 @@ import org.hibernate.event.spi.PostLoadEvent; import org.hibernate.event.spi.PostLoadEventListener; import org.hibernate.event.spi.PreLoadEvent; import org.hibernate.event.spi.PreLoadEventListener; -import org.hibernate.graph.spi.AttributeNodeImplementor; -import org.hibernate.graph.spi.GraphImplementor; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.pretty.MessageHelper; @@ -207,8 +205,6 @@ public final class TwoPhaseLoad { String[] propertyNames = persister.getPropertyNames(); final Type[] types = persister.getPropertyTypes(); - final GraphImplementor fetchGraphContext = session.getFetchGraphLoadContext(); - for ( int i = 0; i < hydratedState.length; i++ ) { final Object value = hydratedState[i]; if ( debugEnabled ) { @@ -257,10 +253,6 @@ public final class TwoPhaseLoad { LOG.debugf( "Skipping attribute : `%s`", propertyNames[i] ); } } - - if ( session.getFetchGraphLoadContext() != fetchGraphContext ) { - session.setFetchGraphLoadContext( fetchGraphContext ); - } } } @@ -414,11 +406,7 @@ public final class TwoPhaseLoad { } /** - * Check if eager of the association is overridden (i.e. skipping metamodel strategy), including (order sensitive): - *
    - *
  1. fetch graph
  2. - *
  3. fetch profile
  4. - *
+ * Check if eager of the association is overridden by anything. * * @param session session * @param entityName entity name @@ -436,25 +424,8 @@ public final class TwoPhaseLoad { // Performance: check type.isCollectionType() first, as type.isAssociationType() is megamorphic if ( associationType.isCollectionType() || associationType.isAssociationType() ) { - // check 'fetch graph' first; skip 'fetch profile' if 'fetch graph' takes effect - Boolean overridingEager = isEagerFetchGraph( session, associationName, associationType ); - - if ( overridingEager != null ) { - //This method is very hot, and private so let's piggy back on the fact that the caller already knows the debugging state. - if ( isDebugEnabled ) { - LOG.debugf( - "Overriding eager fetching using fetch graph. EntityName: %s, associationName: %s, eager fetching: %s", - entityName, - associationName, - overridingEager - ); - } - - return overridingEager; - } - // check 'fetch profile' next; skip 'metamodel' if 'fetch profile' takes effect - overridingEager = isEagerFetchProfile( session, entityName, associationName ); + final Boolean overridingEager = isEagerFetchProfile( session, entityName, associationName ); if ( overridingEager != null ) { //This method is very hot, and private so let's piggy back on the fact that the caller already knows the debugging state. @@ -492,39 +463,6 @@ public final class TwoPhaseLoad { return null; } - - private static Boolean isEagerFetchGraph(SharedSessionContractImplementor session, String associationName, Type associationType) { - final GraphImplementor context = session.getFetchGraphLoadContext(); - - if ( context != null ) { - // 'fetch graph' is in effect, so null should not be returned - final AttributeNodeImplementor attributeNode = context.findAttributeNode( associationName ); - if ( attributeNode != null ) { - if ( associationType.isCollectionType() ) { - // to do: deal with Map's key and value - session.setFetchGraphLoadContext( null ); - } - else { - // set 'fetchGraphContext' to sub-graph so graph is explored further (internal loading) - final GraphImplementor subContext = attributeNode.getSubGraphMap().get( associationType.getReturnedClass() ); - if ( subContext != null ) { - session.setFetchGraphLoadContext( subContext ); - } - else { - session.setFetchGraphLoadContext( null ); - } - } - // explicit 'fetch graph' applies, so fetch eagerly - return true; - } - else { - // implicit 'fetch graph' applies, so fetch lazily - return false; - } - } - - return null; - } /** * This method will be removed. diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java index a80fa0a6b8..646fab72cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java @@ -30,7 +30,6 @@ import org.hibernate.engine.jdbc.LobCreationContext; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.query.spi.sql.NativeSQLQuerySpecification; -import org.hibernate.graph.spi.GraphImplementor; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.jpa.spi.HibernateEntityManagerImplementor; import org.hibernate.loader.custom.CustomQuery; @@ -523,31 +522,4 @@ public interface SharedSessionContractImplementor */ PersistenceContext getPersistenceContextInternal(); - /** - * Get the current fetch graph context (either {@link org.hibernate.graph.spi.RootGraphImplementor} or {@link org.hibernate.graph.spi.SubGraphImplementor}. - * Suppose fetch graph is "a(b(c))", then during {@link org.hibernate.engine.internal.TwoPhaseLoad}: - *
    - *
  • when loading root
  • : {@link org.hibernate.graph.spi.RootGraphImplementor root} will be returned - *
  • when internally loading 'a'
  • : {@link org.hibernate.graph.spi.SubGraphImplementor subgraph} of 'a' will be returned - *
  • when internally loading 'b'
  • : {@link org.hibernate.graph.spi.SubGraphImplementor subgraph} of 'a(b)' will be returned - *
  • when internally loading 'c'
  • : {@link org.hibernate.graph.spi.SubGraphImplementor subgraph} of 'a(b(c))' will be returned - *
- * - * @return current fetch graph context; can be null if fetch graph is not effective or the graph eager loading is done. - * @see #setFetchGraphLoadContext(GraphImplementor) - * @see org.hibernate.engine.internal.TwoPhaseLoad - */ - default GraphImplementor getFetchGraphLoadContext() { - return null; - } - - /** - * Set the current fetch graph context (either {@link org.hibernate.graph.spi.RootGraphImplementor} or {@link org.hibernate.graph.spi.SubGraphImplementor}. - * - * @param fetchGraphLoadContext new fetch graph context; can be null (this field will be set to null after root entity loading is done). - * @see #getFetchGraphLoadContext() - */ - default void setFetchGraphLoadContext(GraphImplementor fetchGraphLoadContext) { - } - } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 8be3794dfa..096839e828 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -130,7 +130,6 @@ import org.hibernate.event.spi.SaveOrUpdateEventListener; import org.hibernate.graph.GraphSemantic; import org.hibernate.graph.RootGraph; import org.hibernate.graph.internal.RootGraphImpl; -import org.hibernate.graph.spi.GraphImplementor; import org.hibernate.graph.spi.RootGraphImplementor; import org.hibernate.hql.spi.QueryTranslator; import org.hibernate.internal.CriteriaImpl.CriterionEntry; @@ -215,8 +214,6 @@ public class SessionImpl private transient LoadEvent loadEvent; //cached LoadEvent instance private transient TransactionObserver transactionObserver; - - private transient GraphImplementor fetchGraphLoadContext; public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) { super( factory, options ); @@ -3316,10 +3313,6 @@ public class SessionImpl loadAccess.with( lockOptions ); } - if ( getLoadQueryInfluencers().getEffectiveEntityGraph().getSemantic() == GraphSemantic.FETCH ) { - setFetchGraphLoadContext( getLoadQueryInfluencers().getEffectiveEntityGraph().getGraph() ); - } - return loadAccess.load( (Serializable) primaryKey ); } catch ( EntityNotFoundException ignored ) { @@ -3364,7 +3357,6 @@ public class SessionImpl finally { getLoadQueryInfluencers().getEffectiveEntityGraph().clear(); getLoadQueryInfluencers().setReadOnly( null ); - setFetchGraphLoadContext( null ); } } @@ -3737,16 +3729,6 @@ public class SessionImpl checkOpen(); return getEntityManagerFactory().findEntityGraphsByType( entityClass ); } - - @Override - public GraphImplementor getFetchGraphLoadContext() { - return this.fetchGraphLoadContext; - } - - @Override - public void setFetchGraphLoadContext(GraphImplementor fetchGraphLoadContext) { - this.fetchGraphLoadContext = fetchGraphLoadContext; - } /** * Used by JDK serialization... diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java b/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java index b16f8256e3..594c1b60fd 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java @@ -1437,9 +1437,6 @@ public abstract class AbstractProducedQuery implements QueryImplementor { sessionCacheMode = getProducer().getCacheMode(); getProducer().setCacheMode( effectiveCacheMode ); } - if ( entityGraphQueryHint != null && entityGraphQueryHint.getSemantic() == GraphSemantic.FETCH ) { - getProducer().setFetchGraphLoadContext( entityGraphQueryHint.getGraph() ); - } } protected void afterQuery() { @@ -1451,7 +1448,6 @@ public abstract class AbstractProducedQuery implements QueryImplementor { getProducer().setCacheMode( sessionCacheMode ); sessionCacheMode = null; } - getProducer().setFetchGraphLoadContext( null ); } @Override From 99a4edfac0ed31f2cfedfd7cbfb5e5a32edf114f Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Sun, 13 Sep 2020 09:43:17 -0400 Subject: [PATCH 16/16] HHH-14212 fix Fetch Graph by simply returning false in TwoPhaseLoad#getOverridingEager() when Fetch Graph is being enforced --- .../engine/internal/TwoPhaseLoad.java | 14 +- .../spi/SharedSessionContractImplementor.java | 7 + .../org/hibernate/internal/SessionImpl.java | 18 ++ .../query/internal/AbstractProducedQuery.java | 4 + .../jpa/test/graphs/FetchGraphTest.java | 176 ++++++++++++++++++ 5 files changed, 217 insertions(+), 2 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/FetchGraphTest.java diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java index 70956b6281..8dfc849ed5 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java @@ -204,7 +204,7 @@ public final class TwoPhaseLoad { String entityName = persister.getEntityName(); String[] propertyNames = persister.getPropertyNames(); final Type[] types = persister.getPropertyTypes(); - + for ( int i = 0; i < hydratedState.length; i++ ) { final Object value = hydratedState[i]; if ( debugEnabled ) { @@ -406,7 +406,11 @@ public final class TwoPhaseLoad { } /** - * Check if eager of the association is overridden by anything. + * Check if eager of the association is overridden (i.e. skipping metamodel strategy), including (order sensitive): + *
    + *
  1. fetch graph
  2. + *
  3. fetch profile
  4. + *
* * @param session session * @param entityName entity name @@ -424,6 +428,12 @@ public final class TwoPhaseLoad { // Performance: check type.isCollectionType() first, as type.isAssociationType() is megamorphic if ( associationType.isCollectionType() || associationType.isAssociationType() ) { + // we can return false invariably for if the entity has been covered by entity graph, + // its associated JOIN has been present in the SQL generated and hence it would be loaded anyway + if ( session.isEnforcingFetchGraph() ) { + return false; + } + // check 'fetch profile' next; skip 'metamodel' if 'fetch profile' takes effect final Boolean overridingEager = isEagerFetchProfile( session, entityName, associationName ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java index 646fab72cf..af3a118407 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SharedSessionContractImplementor.java @@ -522,4 +522,11 @@ public interface SharedSessionContractImplementor */ PersistenceContext getPersistenceContextInternal(); + default boolean isEnforcingFetchGraph() { + return false; + } + + default void setEnforcingFetchGraph(boolean enforcingFetchGraph) { + } + } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 096839e828..0a0396681f 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -215,6 +215,8 @@ public class SessionImpl private transient TransactionObserver transactionObserver; + private transient boolean isEnforcingFetchGraph; + public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) { super( factory, options ); @@ -3312,6 +3314,10 @@ public class SessionImpl lockOptions = buildLockOptions( lockModeType, properties ); loadAccess.with( lockOptions ); } + + if ( getLoadQueryInfluencers().getEffectiveEntityGraph().getSemantic() == GraphSemantic.FETCH ) { + setEnforcingFetchGraph( true ); + } return loadAccess.load( (Serializable) primaryKey ); } @@ -3357,6 +3363,7 @@ public class SessionImpl finally { getLoadQueryInfluencers().getEffectiveEntityGraph().clear(); getLoadQueryInfluencers().setReadOnly( null ); + setEnforcingFetchGraph( false ); } } @@ -3785,4 +3792,15 @@ public class SessionImpl } return readOnly; } + + @Override + public boolean isEnforcingFetchGraph() { + return this.isEnforcingFetchGraph; + } + + @Override + public void setEnforcingFetchGraph(boolean isEnforcingFetchGraph) { + this.isEnforcingFetchGraph = isEnforcingFetchGraph; + } + } diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java b/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java index 594c1b60fd..06088bf56d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/AbstractProducedQuery.java @@ -1437,6 +1437,9 @@ public abstract class AbstractProducedQuery implements QueryImplementor { sessionCacheMode = getProducer().getCacheMode(); getProducer().setCacheMode( effectiveCacheMode ); } + if ( entityGraphQueryHint != null && entityGraphQueryHint.getSemantic() == GraphSemantic.FETCH ) { + getProducer().setEnforcingFetchGraph( true ); + } } protected void afterQuery() { @@ -1448,6 +1451,7 @@ public abstract class AbstractProducedQuery implements QueryImplementor { getProducer().setCacheMode( sessionCacheMode ); sessionCacheMode = null; } + getProducer().setEnforcingFetchGraph( false ); } @Override diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/FetchGraphTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/FetchGraphTest.java new file mode 100644 index 0000000000..bda766214a --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/FetchGraphTest.java @@ -0,0 +1,176 @@ +package org.hibernate.jpa.test.graphs; + +import java.util.Arrays; +import java.util.List; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.EntityGraph; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +import org.hibernate.Hibernate; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.graph.GraphParser; +import org.hibernate.graph.GraphSemantic; +import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; + +import org.hibernate.testing.TestForIssue; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +/** + * @author Yaroslav Prokipchyn + * @author Nathan Xu + */ +@TestForIssue( jiraKey = "HHH-14212" ) +public class FetchGraphTest extends BaseEntityManagerFunctionalTestCase { + + @Override + protected Class[] getAnnotatedClasses() { + return new Class[] { + LedgerRecord.class, + LedgerRecordItem.class, + BudgetRecord.class, + Trigger.class, + FinanceEntity.class + }; + } + + @Before + public void setUp() { + doInJPA( this::entityManagerFactory, entityManager -> { + Trigger trigger = new Trigger(); + entityManager.persist( trigger ); + + BudgetRecord budgetRecord = new BudgetRecord(); + budgetRecord.amount = 100; + budgetRecord.trigger = trigger; + entityManager.persist( budgetRecord ); + + FinanceEntity client = new FinanceEntity(); + client.name = "client"; + FinanceEntity vendor = new FinanceEntity(); + vendor.name = "vendor"; + entityManager.persist( client ); + entityManager.persist( vendor ); + + LedgerRecordItem item1 = new LedgerRecordItem(); + item1.financeEntity = client; + LedgerRecordItem item2 = new LedgerRecordItem(); + item2.financeEntity = vendor; + entityManager.persist( item1 ); + entityManager.persist( item2 ); + + LedgerRecord ledgerRecord = new LedgerRecord(); + ledgerRecord.budgetRecord = budgetRecord; + ledgerRecord.trigger = trigger; + ledgerRecord.ledgerRecordItems= Arrays.asList( item1, item2 ); + + item1.ledgerRecord = ledgerRecord; + item2.ledgerRecord = ledgerRecord; + + entityManager.persist( ledgerRecord ); + } ); + } + + @Test + public void testCollectionEntityGraph() { + doInJPA( this::entityManagerFactory, entityManager -> { + final EntityGraph entityGraph = GraphParser.parse( LedgerRecord.class, "budgetRecord, ledgerRecordItems.value(financeEntity)", entityManager ); + final List records = entityManager.createQuery( "from LedgerRecord", LedgerRecord.class ) + .setHint( GraphSemantic.FETCH.getJpaHintName(), entityGraph ) + .getResultList(); + assertThat( records.size(), is( 1 ) ); + records.forEach( record -> { + assertFalse( Hibernate.isInitialized( record.trigger ) ); + assertTrue( Hibernate.isInitialized( record.budgetRecord ) ); + assertFalse( Hibernate.isInitialized( record.budgetRecord.trigger ) ); + assertTrue( Hibernate.isInitialized( record.ledgerRecordItems) ); + assertThat( record.ledgerRecordItems.size(), is( 2 ) ); + record.ledgerRecordItems.forEach( item -> { + assertSame( record, item.ledgerRecord ); + assertTrue( Hibernate.isInitialized( item.financeEntity ) ); + } ); + } ); + } ); + } + + @Entity(name = "LedgerRecord") + @Table(name = "LedgerRecord") + static class LedgerRecord { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + Integer id; + + @ManyToOne + BudgetRecord budgetRecord; + + @OneToMany(mappedBy = "ledgerRecord", fetch = FetchType.EAGER, cascade = CascadeType.ALL) + @Fetch(FetchMode.SUBSELECT) + List ledgerRecordItems; + + @ManyToOne + Trigger trigger; + } + + @Entity(name = "LedgerRecordItem") + @Table(name = "LedgerRecordItem") + static class LedgerRecordItem { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + Integer id; + + @ManyToOne + LedgerRecord ledgerRecord; + + @ManyToOne + FinanceEntity financeEntity; + } + + @Entity(name = "BudgetRecord") + @Table(name = "BudgetRecord") + static class BudgetRecord { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + Integer id; + + int amount; + + @ManyToOne + Trigger trigger; + } + + @Entity(name = "Trigger") + @Table(name = "Trigger") + static class Trigger { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + Integer id; + + String name; + } + + @Entity(name = "FinanceEntity") + @Table(name = "FinanceEntity") + static class FinanceEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + Integer id; + + String name; + } +} +