diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
index a0c71dbfa416..33b751ca7eae 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
@@ -106,6 +106,7 @@ public interface AvailableSettings
* @since 5.3
*/
@Deprecated(since = "7.0", forRemoval = true)
+ @SuppressWarnings("DeprecatedIsStillUsed")
String DELAY_ENTITY_LOADER_CREATIONS = "hibernate.loader.delay_entity_loader_creations";
/**
@@ -157,6 +158,7 @@ public interface AvailableSettings
* @deprecated This is no longer useful and will be removed.
*/
@Deprecated(since = "7.0", forRemoval = true)
+ @SuppressWarnings("DeprecatedIsStillUsed")
String DISCARD_PC_ON_CLOSE = "hibernate.discard_pc_on_close";
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/BatchSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/BatchSettings.java
index 01e89517eba2..f6e7e522b4e2 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/BatchSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/BatchSettings.java
@@ -69,5 +69,6 @@ public interface BatchSettings {
* @deprecated Use {@link #BUILDER} instead
*/
@Deprecated(since="6.4")
+ @SuppressWarnings("DeprecatedIsStillUsed")
String BATCH_STRATEGY = "hibernate.jdbc.factory_class";
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/BytecodeSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/BytecodeSettings.java
index 30a425fac764..b2e61cab685f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/BytecodeSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/BytecodeSettings.java
@@ -24,6 +24,7 @@ public interface BytecodeSettings {
* See HHH-17643
*/
@Deprecated( forRemoval = true )
+ @SuppressWarnings("DeprecatedIsStillUsed")
String BYTECODE_PROVIDER = "hibernate.bytecode.provider";
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/JdbcSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/JdbcSettings.java
index 4c59d442ecd6..a4b7062ad590 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/JdbcSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/JdbcSettings.java
@@ -15,7 +15,7 @@
import org.hibernate.sql.ast.spi.ParameterMarkerStrategy;
/**
- * Settings related to JDBC, Connections, pools, Dialects, etc
+ * Settings related to JDBC, Connections, pools, Dialects, and so on.
*
* @author Steve Ebersole
*/
@@ -162,7 +162,7 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
/**
* Used in conjunction with {@value #JAKARTA_HBM2DDL_DB_NAME} for the purpose of
* determining the {@link org.hibernate.dialect.Dialect} to use when the name does
- * not provide enough detail.
+ * not provide enough information.
*
* The value is expected to match what would be returned from
* {@link java.sql.DatabaseMetaData#getDatabaseProductVersion()}) for the
@@ -175,7 +175,7 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
/**
* Used in conjunction with {@value #JAKARTA_HBM2DDL_DB_NAME} for the purpose of
* determining the {@link org.hibernate.dialect.Dialect} to use when the name does
- * not provide enough detail.
+ * not provide enough information.
*
* The value is expected to match what would be returned from
* {@link java.sql.DatabaseMetaData#getDatabaseMajorVersion()}) for the underlying
@@ -188,7 +188,7 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
/**
* Used in conjunction with {@value #JAKARTA_HBM2DDL_DB_NAME} for the purpose of
* determining the {@link org.hibernate.dialect.Dialect} to use when the name does
- * not provide enough detail.
+ * not provide enough information.
*
* The value is expected to match what would be returned from
* {@link java.sql.DatabaseMetaData#getDatabaseMinorVersion()}) for the underlying
@@ -258,7 +258,7 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
* The default implementation is not recommended for use in production.
*
* @apiNote The term {@code "class"} appears in the setting name due to legacy reasons;
- * however it can accept instances.
+ * however, it can accept instances.
*/
String CONNECTION_PROVIDER = "hibernate.connection.provider_class";
@@ -303,14 +303,15 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
/**
* Indicates that connections obtained from the configured {@link ConnectionProvider} have
- * auto-commit already disabled when they are acquired.
+ * {@linkplain java.sql.Connection#getAutoCommit auto-commit} already disabled when they
+ * are acquired.
*
* It is inappropriate to set this value to {@code true} when the connections returned by
* the provider do not, in fact, have auto-commit disabled. Doing so may lead to Hibernate
* executing SQL operations outside the scope of any transaction.
*
* @apiNote By default, Hibernate calls {@link java.sql.Connection#setAutoCommit(boolean)}
- * on newly-obtained connections. With this setting enabled, that call is skipped, along
+ * on newly obtained connections. With this setting enabled, that call is skipped, along
* with some other operations, in the interest of performance.
*
* @settingDefault {@code false}
@@ -332,6 +333,7 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
* and {@link org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProvider}.
*/
@Deprecated(since="7")
+ @SuppressWarnings("DeprecatedIsStillUsed")
String CONNECTION_PREFIX = "hibernate.connection";
/**
@@ -340,7 +342,7 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
* either:
*
* - an instance of {@code StatementInspector},
- *
- a {@link Class} representing an class that implements {@code StatementInspector}, or
+ *
- a {@link Class} representing a class that implements {@code StatementInspector}, or
*
- the name of a class that implements {@code StatementInspector}.
*
*
@@ -423,6 +425,7 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
* @deprecated It's not necessary to set this explicitly
*/
@Deprecated(since = "7", forRemoval = true)
+ @SuppressWarnings("DeprecatedIsStillUsed")
String USE_SCROLLABLE_RESULTSET = "hibernate.jdbc.use_scrollable_resultset";
/**
@@ -539,12 +542,12 @@ public interface JdbcSettings extends C3p0Settings, AgroalSettings, HikariCPSett
* Whether access to JDBC {@linkplain java.sql.DatabaseMetaData metadata} is allowed during bootstrap.
*
* Typically, Hibernate accesses this metadata to understand the capabilities of the underlying
- * database to help minimize needed configuration. Disabling this access means that only explicit
- * settings are used. At a minimum, the Dialect to use must be specified using either the {@value #DIALECT}
- * or {@value JdbcSettings#JAKARTA_HBM2DDL_DB_NAME} setting. When the Dialect to use is specified in
+ * database to help minimize needed configuration. Disabling this access means that only explicit
+ * settings are used. At a minimum, the Dialect to use must be specified using either the {@value #DIALECT}
+ * or {@value JdbcSettings#JAKARTA_HBM2DDL_DB_NAME} setting. When the Dialect to use is specified in
* this manner it is generally a good idea to specify the
- * {@linkplain JdbcSettings#JAKARTA_HBM2DDL_DB_VERSION database version} as well - Dialects use the version
- * to configure themselves.
+ * {@linkplain JdbcSettings#JAKARTA_HBM2DDL_DB_VERSION database version} as well - Dialects use the
+ * version to configure themselves.
*
* @apiNote The specified Dialect may also provide defaults into the "explicit" settings.
*
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/JpaComplianceSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/JpaComplianceSettings.java
index 693e39447491..47c193d36ed3 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/JpaComplianceSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/JpaComplianceSettings.java
@@ -190,5 +190,6 @@ public interface JpaComplianceSettings {
* @deprecated Prefer {@link #JPA_QUERY_COMPLIANCE}
*/
@Deprecated
+ @SuppressWarnings("DeprecatedIsStillUsed")
String JPAQL_STRICT_COMPLIANCE= "hibernate.query.jpaql_strict_compliance";
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ManagedBeanSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/ManagedBeanSettings.java
index 3b760cb28c23..ba99ca80db48 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ManagedBeanSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/ManagedBeanSettings.java
@@ -80,8 +80,8 @@ public interface ManagedBeanSettings {
String DELAY_CDI_ACCESS = "hibernate.delay_cdi_access";
/**
- * Controls whether Hibernate can try to create beans other than converters
- * and listeners using CDI. Only meaningful when a CDI {@link #BEAN_CONTAINER container}
+ * Controls whether Hibernate can try to create beans other than converters and
+ * listeners using CDI. Only meaningful when a CDI {@link #BEAN_CONTAINER container}
* is used.
*
* By default, Hibernate will only attempt to create converter and listener beans using CDI.
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java
index ebb742465432..561932b649aa 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java
@@ -326,8 +326,8 @@ public interface MappingSettings {
String XML_FORMAT_MAPPER = "hibernate.type.xml_format_mapper";
/**
- * Specifies whether to use the legacy provider specific and non-portable XML format for collections and byte arrays
- * for XML serialization/deserialization.
+ * Specifies whether to use the legacy provider-specific and non-portable XML format for
+ * collections and byte arrays for XML serialization/deserialization.
*
* {@code false} by default. This property only exists for backwards compatibility.
*
@@ -355,8 +355,8 @@ public interface MappingSettings {
* The possible options for this setting are enumerated by
* {@link org.hibernate.annotations.TimeZoneStorageType}.
*
- * @apiNote For backward compatibility with older versions of Hibernate, set this property to
- * {@link org.hibernate.annotations.TimeZoneStorageType#NORMALIZE NORMALIZE}.
+ * @apiNote For backward compatibility with older versions of Hibernate, set this property
+ * to {@link org.hibernate.annotations.TimeZoneStorageType#NORMALIZE NORMALIZE}.
*
* @settingDefault {@link org.hibernate.annotations.TimeZoneStorageType#DEFAULT DEFAULT},
* which guarantees that the {@linkplain java.time.OffsetDateTime#toInstant() instant}
@@ -374,7 +374,7 @@ public interface MappingSettings {
* Used to specify the {@link org.hibernate.boot.model.naming.ImplicitNamingStrategy}
* class to use. The following shortcut names are defined for this setting:
*
- * - {@code "default"} and {@code "jpa"} are an abbreviations for
+ *
- {@code "default"} and {@code "jpa"} are abbreviations for
* {@link org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl}
*
- {@code "legacy-jpa"} is an abbreviation for
* {@link org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl}
@@ -465,7 +465,7 @@ public interface MappingSettings {
* Accepts any of:
*
* - an instance of {@code CollectionClassification}
- *
- the (case insensitive) name of a {@code CollectionClassification} (list e.g.)
+ *
- the (case-insensitive) name of a {@code CollectionClassification} (list e.g.)
*
- a {@link Class} representing either {@link java.util.List} or {@link java.util.Collection}
*
*
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/SchemaToolingSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/SchemaToolingSettings.java
index edad4f95f127..83269ff6ef4d 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/SchemaToolingSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/SchemaToolingSettings.java
@@ -193,9 +193,9 @@ public interface SchemaToolingSettings {
String HBM2DDL_AUTO = "hibernate.hbm2ddl.auto";
/**
- * For cases where the {@value #JAKARTA_HBM2DDL_SCRIPTS_ACTION} value indicates that schema commands
- * should be written to DDL script file, specifies if schema commands should be appended to
- * the end of the file rather than written at the beginning of the file.
+ * For cases where the {@value #JAKARTA_HBM2DDL_SCRIPTS_ACTION} value indicates that schema
+ * commands should be written to a DDL script file, specifies if schema commands should be
+ * appended to the end of the file rather than written at the beginning of the file.
*
* Values are: {@code true} for appending schema commands to the end of the file, {@code false}
* for writing schema commands at the beginning.
@@ -233,9 +233,9 @@ public interface SchemaToolingSettings {
/**
* Used to specify the {@link org.hibernate.tool.schema.spi.SchemaFilterProvider} to be
- * used by create, drop, migrate and validate operations on the database schema. A
+ * used by create, drop, migrate, and validate operations on the database schema. A
* {@code SchemaFilterProvider} provides filters that can be used to limit the scope of
- * these operations to specific namespaces, tables and sequences. All objects are
+ * these operations to specific namespaces, tables, and sequences. All objects are
* included by default.
*
* @since 5.1
@@ -318,7 +318,7 @@ public interface SchemaToolingSettings {
/**
* Specifies a comma-separated list of extra table types, in addition to the
* default types {@code "TABLE"} and {@code "VIEW"}, to recognize as physical
- * tables when performing schema update, creation and validation.
+ * tables when performing schema update, creation, and validation.
*
* @since 5.0
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/TransactionSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/TransactionSettings.java
index d9f0be4fd69f..27b42a1b1d64 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/TransactionSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/TransactionSettings.java
@@ -29,8 +29,8 @@ public interface TransactionSettings {
* @settingDefault With Jakarta Persistence bootstrapping, based on the persistence unit's {@link PersistenceUnitInfo#getTransactionType()};
* otherwise {@code jdbc}.
*
- * @implSpec With non Jakarta Persistence bootstrapping, Hibernate will use {@code jdbc} as the default which
- * will cause problems if the application actually uses JTA-based transactions.
+ * @implSpec With non-Jakarta Persistence bootstrapping, Hibernate will use {@code jdbc} as the
+ * default which will cause problems if the application actually uses JTA-based transactions.
*
* @see #JTA_PLATFORM
*
@@ -152,7 +152,7 @@ public interface TransactionSettings {
* Allows a detached proxy or lazy collection to be fetched even when not
* associated with an open persistence context, by creating a temporary
* persistence context when the proxy or collection is accessed. This
- * behavior is not recommended, since it can easily break transaction
+ * behavior is not recommended since it can easily break transaction
* isolation or lead to data aliasing; it is therefore disabled by default.
*
* @settingDefault {@code false} (disabled)
diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java
index cb932b22f9f2..ce51b8a3e8e6 100644
--- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java
+++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java
@@ -98,7 +98,7 @@
*
* | {@value #VALUE_COLUMN_PARAM} |
* {@value #DEF_VALUE_COLUMN} |
- * The name of column which holds the sequence value for the given segment |
+ * The name of the column which holds the sequence value for the given segment |
*
*
*
@@ -217,7 +217,7 @@ public void configure(GeneratorCreationContext creationContext, Properties param
SEQUENCE_GENERATOR_LOGGER.forcingTableUse();
}
- this.databaseStructure = buildDatabaseStructure(
+ databaseStructure = buildDatabaseStructure(
identifierType,
parameters,
jdbcEnvironment,
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 3d68360beeb5..d043a30411b2 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
@@ -58,12 +58,10 @@
/**
* An enhanced version of table-based id generation.
*
- * Unlike the simplistic legacy one (which was only ever intended for subclassing
- * support) we "segment" the table into multiple values. Thus, a single table can
- * actually serve as the persistent storage for multiple independent generators. One
- * approach would be to segment the values by the name of the entity for which we are
- * performing generation, which would mean that we would have a row in the generator
- * table for each entity name. Or any configuration really; the setup is very flexible.
+ * A single table may serve as the persistent storage for multiple independent generators.
+ * For example, we might segment the generated values by the name of the entity for which
+ * we are generation ids. This, we would have a row in the generator table for each entity
+ * name. Other approaches are also possible.
*
* By default, we use a single row for all generators (the {@value #DEF_SEGMENT_VALUE}
* segment). The configuration parameter {@value #CONFIG_PREFER_SEGMENT_PER_ENTITY} can
@@ -84,7 +82,7 @@
*
* | {@value #VALUE_COLUMN_PARAM} |
* {@value #DEF_VALUE_COLUMN} |
- * The name of column which holds the sequence value for the given segment |
+ * The name of the column which holds the sequence value for the given segment |
*
*
* | {@value #SEGMENT_COLUMN_PARAM} |
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/AbstractUserDefinedType.java b/hibernate-core/src/main/java/org/hibernate/mapping/AbstractUserDefinedType.java
index bd236a5ea56f..44267f4ba605 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/AbstractUserDefinedType.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/AbstractUserDefinedType.java
@@ -68,10 +68,9 @@ public boolean isQuoted() {
}
public void setQuoted(boolean quoted) {
- if ( quoted == name.isQuoted() ) {
- return;
+ if ( quoted != name.isQuoted() ) {
+ name = new Identifier( name.getText(), quoted );
}
- this.name = new Identifier( name.getText(), quoted );
}
public void setSchema(String schema) {
@@ -126,7 +125,9 @@ public int hashCode() {
@Override
public boolean equals(Object object) {
- return object != null && object.getClass() == getClass() && equals( (AbstractUserDefinedType) object);
+ return object != null
+ && object.getClass() == getClass()
+ && equals( (AbstractUserDefinedType) object );
}
public boolean equals(AbstractUserDefinedType table) {
@@ -144,22 +145,22 @@ else if ( this == table ) {
}
public String toString() {
- final StringBuilder buf = new StringBuilder()
+ final var string = new StringBuilder()
.append( getClass().getSimpleName() )
.append( '(' );
if ( getCatalog() != null ) {
- buf.append( getCatalog() ).append( "." );
+ string.append( getCatalog() ).append( "." );
}
if ( getSchema() != null ) {
- buf.append( getSchema() ).append( "." );
+ string.append( getSchema() ).append( "." );
}
- buf.append( getName() ).append( ')' );
- return buf.toString();
+ string.append( getName() ).append( ')' );
+ return string.toString();
}
@Override
public String getExportIdentifier() {
- final StringBuilder qualifiedName = new StringBuilder();
+ final var qualifiedName = new StringBuilder();
if ( catalog != null ) {
qualifiedName.append( catalog.render() ).append( '.' );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/AggregateColumn.java b/hibernate-core/src/main/java/org/hibernate/mapping/AggregateColumn.java
index 0e9ddcd7b55d..24e961c51ac9 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/AggregateColumn.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/AggregateColumn.java
@@ -58,8 +58,8 @@ public SelectablePath getSelectablePath() {
}
private static SelectablePath getSelectablePath(Component component) {
- final AggregateColumn aggregateColumn = component.getAggregateColumn();
- final AggregateColumn parent = component.getParentAggregateColumn();
+ final var aggregateColumn = component.getAggregateColumn();
+ final var parent = component.getParentAggregateColumn();
final String simpleAggregateName = aggregateColumn.getQuotedName();
return parent == null
? new SelectablePath( simpleAggregateName )
@@ -71,8 +71,8 @@ public String getAggregateReadExpressionTemplate(Dialect dialect) {
}
private static String getAggregateReadExpressionTemplate(Dialect dialect, Component component) {
- final AggregateColumn aggregateColumn = component.getAggregateColumn();
- final AggregateColumn parent = component.getParentAggregateColumn();
+ final var aggregateColumn = component.getAggregateColumn();
+ final var parent = component.getParentAggregateColumn();
final String simpleAggregateName = aggregateColumn.getQuotedName( dialect );
// If the aggregate column is an array, drop the parent read expression, because this is a NestedColumnReference
// and will require special rendering
@@ -105,8 +105,8 @@ public String getAggregateAssignmentExpressionTemplate(Dialect dialect) {
}
private static String getAggregateAssignmentExpressionTemplate(Dialect dialect, Component component) {
- final AggregateColumn aggregateColumn = component.getAggregateColumn();
- final AggregateColumn parent = component.getParentAggregateColumn();
+ final var aggregateColumn = component.getAggregateColumn();
+ final var parent = component.getParentAggregateColumn();
final String simpleAggregateName = aggregateColumn.getQuotedName( dialect );
return parent == null
? Template.TEMPLATE + "." + simpleAggregateName
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Array.java b/hibernate-core/src/main/java/org/hibernate/mapping/Array.java
index 47ee926ffa11..f76a4836e317 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Array.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Array.java
@@ -56,7 +56,7 @@ public Class> getElementClass() throws MappingException {
}
else {
try {
- return classForName( elementClassName, getBuildingContext().getBootstrapContext() );
+ return classForName( elementClassName, getBootstrapContext() );
}
catch (ClassLoadingException e) {
throw new MappingException( e );
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java
index 71a6067d04f2..ff4db8c1906e 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java
@@ -476,7 +476,7 @@ private ConverterDescriptor getSoftDeleteConverterDescriptor(
SoftDelete.UnspecifiedConversion.class.equals( attributeConverterDescriptor.getAttributeConverterClass() );
if ( conversionWasUnspecified ) {
final var jdbcType = BooleanJdbcType.INSTANCE.resolveIndicatedType( this, javaType );
- final var classmateContext = getBuildingContext().getBootstrapContext().getClassmateContext();
+ final var classmateContext = getBootstrapContext().getClassmateContext();
if ( jdbcType.isNumber() ) {
return ConverterDescriptors.of( NumericBooleanConverter.INSTANCE, classmateContext );
}
@@ -657,7 +657,7 @@ private Resolution> resolution(BasicJavaType explicitJavaType, JavaType
@Override
public ManagedBeanRegistry getManagedBeanRegistry() {
- return getBuildingContext().getBootstrapContext().getManagedBeanRegistry();
+ return getBootstrapContext().getManagedBeanRegistry();
}
private Resolution> converterResolution(JavaType> javaType, ConverterDescriptor,?> attributeConverterDescriptor) {
@@ -702,8 +702,7 @@ private Resolution> converterResolution(JavaType> javaType, ConverterDescrip
}
private JavaType> determineJavaType() {
- final JavaType> javaType = getExplicitJavaType();
-//
+ final var javaType = getExplicitJavaType();
// if ( javaType == null ) {
// if ( implicitJavaTypeAccess != null ) {
// final java.lang.reflect.Type implicitJtd = implicitJavaTypeAccess.apply( getTypeConfiguration() );
@@ -752,7 +751,7 @@ else if ( ownerName != null && propertyName != null ) {
}
private JavaType> javaType(TypeConfiguration typeConfiguration, java.lang.reflect.Type impliedJavaType) {
- final JavaType> javaType = typeConfiguration.getJavaTypeRegistry().findDescriptor( impliedJavaType );
+ final var javaType = typeConfiguration.getJavaTypeRegistry().findDescriptor( impliedJavaType );
return javaType == null ? specialJavaType( typeConfiguration, impliedJavaType ) : javaType;
}
@@ -765,14 +764,14 @@ private JavaType> specialJavaType(
// and implement toString/fromString as well as copying based on FormatMapper operations
switch ( jdbcTypeCode ) {
case SqlTypes.JSON:
- final JavaType> jsonJavaType =
+ final var jsonJavaType =
new JsonJavaType<>( impliedJavaType,
mutabilityPlan( typeConfiguration, impliedJavaType ),
typeConfiguration );
javaTypeRegistry.addDescriptor( jsonJavaType );
return jsonJavaType;
case SqlTypes.SQLXML:
- final JavaType> xmlJavaType =
+ final var xmlJavaType =
new XmlJavaType<>( impliedJavaType,
mutabilityPlan( typeConfiguration, impliedJavaType ),
typeConfiguration );
@@ -808,7 +807,6 @@ private static Resolution> interpretExplicitlyNamedType(
MetadataBuildingContext context) {
final var bootstrapContext = context.getBootstrapContext();
-
final var managedBeanRegistry = bootstrapContext.getManagedBeanRegistry();
final var typeConfiguration = bootstrapContext.getTypeConfiguration();
@@ -1106,7 +1104,7 @@ private UserType> getConfiguredUserTypeBean(Class extends UserType>> expli
}
private ManagedBean extends T> getUserTypeBean(Class explicitCustomType, Properties properties) {
- final var producer = getBuildingContext().getBootstrapContext().getCustomTypeProducer();
+ final var producer = getBootstrapContext().getCustomTypeProducer();
final var managedBeanRegistry = getManagedBeanRegistry();
if ( isNotEmpty( properties ) ) {
final String name = explicitCustomType.getName() + COUNTER++;
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 cc9006a7604e..7622ad199e03 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Collection.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Collection.java
@@ -185,6 +185,10 @@ public MetadataBuildingContext getBuildingContext() {
return buildingContext;
}
+ BootstrapContext getBootstrapContext() {
+ return getBuildingContext().getBootstrapContext();
+ }
+
public MetadataImplementor getMetadata() {
return getBuildingContext().getMetadataCollector();
}
@@ -224,17 +228,13 @@ public boolean isSorted() {
public Comparator> getComparator() {
if ( comparator == null && comparatorClassName != null ) {
- @SuppressWarnings("rawtypes")
- final Class extends Comparator> clazz =
- classForName( Comparator.class, comparatorClassName, getBuildingContext().getBootstrapContext() );
+ final var clazz = classForName( Comparator.class, comparatorClassName, getBootstrapContext() );
try {
comparator = clazz.getConstructor().newInstance();
}
catch (Exception e) {
- throw new MappingException(
- "Could not instantiate comparator class [" + comparatorClassName
- + "] for collection " + getRole()
- );
+ throw new MappingException( "Could not instantiate comparator class ["
+ + comparatorClassName + "] for collection " + getRole() );
}
}
return comparator;
@@ -466,7 +466,7 @@ else if ( typeName == null ) {
}
private ManagedBean extends UserCollectionType> userTypeBean() {
- final BootstrapContext bootstrapContext = getBuildingContext().getBootstrapContext();
+ final var bootstrapContext = getBootstrapContext();
return createUserTypeBean(
role,
classForName( UserCollectionType.class, typeName, bootstrapContext ),
@@ -546,7 +546,7 @@ private void createForeignKeys() throws MappingException {
key.createForeignKeyOfEntity( entityName );
}
else {
- final Property property = owner.getProperty( referencedPropertyName );
+ final var property = owner.getProperty( referencedPropertyName );
assert property != null;
key.createForeignKeyOfEntity( entityName,
property.getValue().getConstraintColumns() );
@@ -657,16 +657,14 @@ public void addFilter(
boolean autoAliasInjection,
java.util.Map aliasTableMap,
java.util.Map aliasEntityMap) {
- filters.add(
- new FilterConfiguration(
- name,
- condition,
- autoAliasInjection,
- aliasTableMap,
- aliasEntityMap,
- null
- )
- );
+ filters.add( new FilterConfiguration(
+ name,
+ condition,
+ autoAliasInjection,
+ aliasTableMap,
+ aliasEntityMap,
+ null
+ ) );
}
@Override
@@ -680,16 +678,14 @@ public void addManyToManyFilter(
boolean autoAliasInjection,
java.util.Map aliasTableMap,
java.util.Map aliasEntityMap) {
- manyToManyFilters.add(
- new FilterConfiguration(
- name,
- condition,
- autoAliasInjection,
- aliasTableMap,
- aliasEntityMap,
- null
- )
- );
+ manyToManyFilters.add( new FilterConfiguration(
+ name,
+ condition,
+ autoAliasInjection,
+ aliasTableMap,
+ aliasEntityMap,
+ null
+ ) );
}
public List getManyToManyFilters() {
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 dd0c5c9f3f59..f72ee0bea568 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java
@@ -468,7 +468,7 @@ Size calculateColumnSize(Dialect dialect, MappingContext mappingContext) {
if ( type == null ) {
throw new AssertionFailure( "no typing information available to determine column size" );
}
- final JdbcMapping jdbcMapping = (JdbcMapping) type;
+ final var jdbcMapping = (JdbcMapping) type;
final Size size = dialect.getSizeStrategy().resolveSize(
jdbcMapping.getJdbcType(),
jdbcMapping.getJdbcJavaType(),
@@ -550,19 +550,19 @@ public boolean isSqlTypeLob() {
}
public boolean isSqlTypeLob(Metadata mapping) {
- final Database database = mapping.getDatabase();
- final DdlTypeRegistry ddlTypeRegistry = database.getTypeConfiguration().getDdlTypeRegistry();
- final Dialect dialect = database.getDialect();
+ final var database = mapping.getDatabase();
+ final var ddlTypeRegistry = database.getTypeConfiguration().getDdlTypeRegistry();
+ final var dialect = database.getDialect();
if ( sqlTypeLob == null ) {
try {
final int typeCode = getSqlTypeCode( mapping );
- final DdlType descriptor = ddlTypeRegistry.getDescriptor( typeCode );
- if ( descriptor == null ) {
+ final var ddlType = ddlTypeRegistry.getDescriptor( typeCode );
+ if ( ddlType == null ) {
sqlTypeLob = JdbcType.isLob( typeCode );
}
else {
final Size size = getColumnSize( dialect, mapping );
- sqlTypeLob = descriptor.isLob( size );
+ sqlTypeLob = ddlType.isLob( size );
}
}
catch ( MappingException cause ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Component.java b/hibernate-core/src/main/java/org/hibernate/mapping/Component.java
index 0d169e1d8767..33462c3bcf2b 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Component.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Component.java
@@ -22,7 +22,6 @@
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.boot.model.source.internal.hbm.MappingDocument;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
-import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
@@ -189,7 +188,7 @@ public void addColumn(Column column) {
@Override
public List getSelectables() {
final List selectables = new ArrayList<>( properties.size() + 2 );
- for ( Property property : properties ) {
+ for ( var property : properties ) {
selectables.addAll( property.getSelectables() );
}
if ( discriminator != null ) {
@@ -201,7 +200,7 @@ public List getSelectables() {
@Override
public List getColumns() {
final List columns = new ArrayList<>( properties.size() + 2 );
- for ( Property property : properties ) {
+ for ( var property : properties ) {
columns.addAll( property.getValue().getColumns() );
}
if ( discriminator != null ) {
@@ -235,9 +234,9 @@ public List getAggregatedColumns() {
}
private void collectAggregatedColumns(List aggregatedColumns, Component component) {
- for ( Property property : component.getProperties() ) {
+ for ( var property : component.getProperties() ) {
if ( property.getValue() instanceof Component subComponent ) {
- final AggregateColumn subAggregate = subComponent.getAggregateColumn();
+ final var subAggregate = subComponent.getAggregateColumn();
if ( subAggregate != null ) {
aggregatedColumns.add( subAggregate );
}
@@ -255,10 +254,10 @@ private void collectAggregatedColumns(List aggregatedColumns, Component
}
private void notifyPropertiesAboutAggregateColumn(AggregateColumn aggregateColumn, Component component) {
- for ( Property property : component.getProperties() ) {
+ for ( var property : component.getProperties() ) {
// Let the BasicValue of every sub-column know about the aggregate,
// which is needed in type resolution
- final Value value = property.getValue();
+ final var value = property.getValue();
if ( value instanceof BasicValue basicValue ) {
assert basicValue.getResolution() == null;
basicValue.setAggregateColumn( aggregateColumn );
@@ -300,7 +299,7 @@ public void checkColumnDuplication(Set distinctColumns, String owner) {
// We can allow different subtypes reusing the same columns
// since only one subtype can exist at one time
final Map> distinctColumnsByClass = new HashMap<>();
- for ( Property prop : properties ) {
+ for ( var prop : properties ) {
if ( prop.isUpdatable() || prop.isInsertable() ) {
final String declaringClass = propertyDeclaringClasses.get( prop );
final Set set = distinctColumnsByClass.computeIfAbsent(
@@ -310,7 +309,7 @@ public void checkColumnDuplication(Set distinctColumns, String owner) {
prop.getValue().checkColumnDuplication( set, owner );
}
}
- for ( Set columns : distinctColumnsByClass.values() ) {
+ for ( var columns : distinctColumnsByClass.values() ) {
distinctColumns.addAll( columns );
}
}
@@ -335,7 +334,7 @@ public Class> getComponentClass() throws MappingException {
}
else {
try {
- componentClass = classForName( componentClassName, getBuildingContext().getBootstrapContext() );
+ componentClass = classForName( componentClassName, getBootstrapContext() );
}
catch (ClassLoadingException e) {
throw new MappingException( "Embeddable class not found: " + componentClassName, e );
@@ -380,11 +379,9 @@ public void setDynamic(boolean dynamic) {
}
private CompositeUserType> createCompositeUserType(Component component) {
- final MetadataBuildingContext buildingContext = getBuildingContext();
- final BootstrapContext bootstrapContext = buildingContext.getBootstrapContext();
- @SuppressWarnings("rawtypes")
- final Class extends CompositeUserType> clazz =
- classForName( CompositeUserType.class, component.getTypeName(), bootstrapContext );
+ final var buildingContext = getBuildingContext();
+ final var bootstrapContext = buildingContext.getBootstrapContext();
+ final var clazz = classForName( CompositeUserType.class, component.getTypeName(), bootstrapContext );
return buildingContext.getBuildingOptions().isAllowExtensionsInCdi()
? bootstrapContext.getManagedBeanRegistry().getBean( clazz ).getBeanInstance()
: FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( clazz );
@@ -476,8 +473,8 @@ public boolean isSame(Component other) {
public boolean[] getColumnInsertability() {
final boolean[] result = new boolean[getColumnSpan()];
int i = 0;
- for ( Property prop : getProperties() ) {
- i += copyFlags( prop.getValue().getColumnInsertability(), result, i, prop.isInsertable() );
+ for ( var property : getProperties() ) {
+ i += copyFlags( property.getValue().getColumnInsertability(), result, i, property.isInsertable() );
}
if ( isPolymorphic() ) {
i += copyFlags( getDiscriminator().getColumnInsertability(), result, i, true );
@@ -495,7 +492,7 @@ private static int copyFlags(boolean[] chunk, boolean[] result, int i, boolean d
@Override
public boolean hasAnyInsertableColumns() {
- for ( Property property : properties ) {
+ for ( var property : properties ) {
if ( property.getValue().hasAnyInsertableColumns() ) {
return true;
}
@@ -506,10 +503,10 @@ public boolean hasAnyInsertableColumns() {
@Override
public boolean[] getColumnUpdateability() {
- boolean[] result = new boolean[getColumnSpan()];
+ final boolean[] result = new boolean[getColumnSpan()];
int i = 0;
- for ( Property prop : getProperties() ) {
- i += copyFlags( prop.getValue().getColumnUpdateability(), result, i, prop.isUpdatable() );
+ for ( var property : getProperties() ) {
+ i += copyFlags( property.getValue().getColumnUpdateability(), result, i, property.isUpdatable() );
}
if ( isPolymorphic() ) {
i += copyFlags( getDiscriminator().getColumnUpdateability(), result, i, true );
@@ -520,7 +517,7 @@ public boolean[] getColumnUpdateability() {
@Override
public boolean hasAnyUpdatableColumns() {
- for ( Property property : properties ) {
+ for ( var property : properties ) {
if ( property.getValue().hasAnyUpdatableColumns() ) {
return true;
}
@@ -550,9 +547,9 @@ public Property getProperty(int index) {
@Override
public Property getProperty(String propertyName) throws MappingException {
- for ( Property prop : properties ) {
- if ( prop.getName().equals(propertyName) ) {
- return prop;
+ for ( var property : properties ) {
+ if ( property.getName().equals(propertyName) ) {
+ return property;
}
}
throw new MappingException("component: " + componentClassName + " property not found: " + propertyName);
@@ -662,7 +659,7 @@ private Generator buildIdentifierGenerator(Dialect dialect, RootClass rootClass,
);
final var properties = getProperties();
for ( int i = 0; i < properties.size(); i++ ) {
- final Property property = properties.get( i );
+ final var property = properties.get( i );
if ( property.getValue().isSimpleValue() ) {
final SimpleValue value = (SimpleValue) property.getValue();
if ( !value.getCustomIdGeneratorCreator().isAssigned() ) {
@@ -882,13 +879,13 @@ private int[] sortProperties(boolean forceRetainOriginalOrder) {
originalPropertyOrder = null;
}
if ( isKey ) {
- final PrimaryKey primaryKey = getOwner().getTable().getPrimaryKey();
+ final var primaryKey = getOwner().getTable().getPrimaryKey();
if ( primaryKey != null ) {
// We have to re-order the primary key accordingly
- final List columns = primaryKey.getColumns();
+ final var columns = primaryKey.getColumns();
columns.clear();
- for ( Property property : properties ) {
- for ( Selectable selectable : property.getSelectables() ) {
+ for ( var property : properties ) {
+ for ( var selectable : property.getSelectables() ) {
if ( selectable instanceof Column column ) {
columns.add( column );
}
@@ -907,7 +904,7 @@ public boolean isSimpleRecord() {
Boolean simple = simpleRecord;
if ( simple == null ) {
// A simple record is given, when the properties match the order of the record component names
- final Class> componentClass = resolveComponentClass();
+ final var componentClass = resolveComponentClass();
if ( customInstantiator != null ) {
return simpleRecord = false;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Constraint.java b/hibernate-core/src/main/java/org/hibernate/mapping/Constraint.java
index 221d770159e2..395d8aaee123 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Constraint.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Constraint.java
@@ -53,7 +53,7 @@ public void addColumn(Column column) {
}
public void addColumns(Value value) {
- for ( Selectable selectable : value.getSelectables() ) {
+ for ( var selectable : value.getSelectables() ) {
if ( selectable.isFormula() ) {
throw new MappingException( "constraint involves a formula: " + name );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/DenormalizedTable.java b/hibernate-core/src/main/java/org/hibernate/mapping/DenormalizedTable.java
index 9118803aee97..bad28f375118 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/DenormalizedTable.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/DenormalizedTable.java
@@ -60,15 +60,15 @@ public DenormalizedTable(
@Override
public void createForeignKeys(MetadataBuildingContext context) {
includedTable.createForeignKeys( context );
- for ( ForeignKey foreignKey : includedTable.getForeignKeyCollection() ) {
- final PersistentClass referencedClass =
+ for ( var foreignKey : includedTable.getForeignKeyCollection() ) {
+ final var referencedClass =
foreignKey.resolveReferencedClass( context.getMetadataCollector() );
// the ForeignKeys created in the first pass did not have their referenced table initialized
if ( foreignKey.getReferencedTable() == null ) {
foreignKey.setReferencedTable( referencedClass.getTable() );
}
- final ForeignKey denormalizedForeignKey = createDenormalizedForeignKey( foreignKey );
+ final var denormalizedForeignKey = createDenormalizedForeignKey( foreignKey );
createForeignKey(
context.getBuildingOptions()
.getImplicitNamingStrategy()
@@ -84,13 +84,13 @@ public void createForeignKeys(MetadataBuildingContext context) {
}
private ForeignKey createDenormalizedForeignKey(ForeignKey includedTableFk) {
- final ForeignKey denormalizedForeignKey = new ForeignKey(this);
+ final var denormalizedForeignKey = new ForeignKey(this);
denormalizedForeignKey.setReferencedEntityName( includedTableFk.getReferencedEntityName() );
denormalizedForeignKey.setKeyDefinition( includedTableFk.getKeyDefinition() );
denormalizedForeignKey.setOptions( includedTableFk.getOptions() );
denormalizedForeignKey.setReferencedTable( includedTableFk.getReferencedTable() );
denormalizedForeignKey.addReferencedColumns( includedTableFk.getReferencedColumns() );
- for ( Column keyColumn : includedTableFk.getColumns() ) {
+ for ( var keyColumn : includedTableFk.getColumns() ) {
denormalizedForeignKey.addColumn( keyColumn );
}
return denormalizedForeignKey;
@@ -98,12 +98,12 @@ private ForeignKey createDenormalizedForeignKey(ForeignKey includedTableFk) {
@Override
public Column getColumn(Column column) {
- Column superColumn = super.getColumn( column );
+ final var superColumn = super.getColumn( column );
return superColumn != null ? superColumn : includedTable.getColumn(column);
}
public Column getColumn(Identifier name) {
- Column superColumn = super.getColumn( name );
+ final var superColumn = super.getColumn( name );
return superColumn != null ? superColumn : includedTable.getColumn(name);
}
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 8568c9be0d58..ba829f73db95 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java
@@ -65,12 +65,12 @@ public Table getReferencedTable() {
return referencedTable;
}
- private void appendColumns(StringBuilder buf, Iterator columns) {
+ private void appendColumns(StringBuilder stringBuilder, Iterator columns) {
while ( columns.hasNext() ) {
- Column column = columns.next();
- buf.append( column.getName() );
+ final var column = columns.next();
+ stringBuilder.append( column.getName() );
if ( columns.hasNext() ) {
- buf.append( "," );
+ stringBuilder.append( "," );
}
}
}
@@ -87,26 +87,15 @@ public void setReferencedTable(Table referencedTable) throws MappingException {
public void alignColumns() {
if ( isReferenceToPrimaryKey() ) {
final int columnSpan = getColumnSpan();
- final PrimaryKey primaryKey = referencedTable.getPrimaryKey();
+ final var primaryKey = referencedTable.getPrimaryKey();
if ( primaryKey.getColumnSpan() != columnSpan ) {
- StringBuilder sb = new StringBuilder();
- sb.append( "Foreign key (" ).append( getName() ).append( ":" )
- .append( getTable().getName() )
- .append( " [" );
- appendColumns( sb, getColumns().iterator() );
- sb.append( "])" )
- .append( ") must have same number of columns as the referenced primary key (" )
- .append( referencedTable.getName() )
- .append( " [" );
- appendColumns( sb, primaryKey.getColumns().iterator() );
- sb.append( "])" );
- throw new MappingException( sb.toString() );
+ throw new MappingException( unalignedColumnsMessage( primaryKey ) );
}
//TODO: shouldn't this happen even for non-PK references?
for ( int i = 0; i referencedColumns) {
- for (Column referencedColumn : referencedColumns) {
+ for ( var referencedColumn : referencedColumns ) {
// if ( !referencedColumn.isFormula() ) {
addReferencedColumn( referencedColumn );
// }
@@ -193,12 +197,12 @@ public PersistentClass resolveReferencedClass(Metadata metadata) {
"' does not specify the referenced entity" );
}
- final PersistentClass referencedClass = metadata.getEntityBinding( referencedEntityName );
- if ( referencedClass == null ) {
+ final var referencedEntity = metadata.getEntityBinding( referencedEntityName );
+ if ( referencedEntity == null ) {
throw new MappingException( "An association from the table '" + getTable().getName() +
"' refers to an unmapped class '" + referencedEntityName + "'" );
}
- return referencedClass;
+ return referencedEntity;
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/IdentifierCollection.java b/hibernate-core/src/main/java/org/hibernate/mapping/IdentifierCollection.java
index 18e4c6862618..f83bbd1ded5e 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/IdentifierCollection.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/IdentifierCollection.java
@@ -63,9 +63,9 @@ public boolean isSame(IdentifierCollection other) {
void createPrimaryKey() {
if ( !isOneToMany() ) {
- PrimaryKey pk = new PrimaryKey( getCollectionTable() );
- pk.addColumns( getIdentifier() );
- getCollectionTable().setPrimaryKey(pk);
+ final var primaryKey = new PrimaryKey( getCollectionTable() );
+ primaryKey.addColumns( getIdentifier() );
+ getCollectionTable().setPrimaryKey(primaryKey);
}
// create an index on the key columns??
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/IndexedCollection.java b/hibernate-core/src/main/java/org/hibernate/mapping/IndexedCollection.java
index 7c1358146062..6413360c5509 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/IndexedCollection.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/IndexedCollection.java
@@ -65,24 +65,24 @@ public boolean isSame(IndexedCollection other) {
void createPrimaryKey() {
if ( !isOneToMany() ) {
- final PrimaryKey pk = new PrimaryKey( getCollectionTable() );
- pk.addColumns( getKey() );
+ final var primaryKey = new PrimaryKey( getCollectionTable() );
+ primaryKey.addColumns( getKey() );
// index should be last column listed
boolean indexIsPartOfElement = false;
- for ( Selectable selectable: getIndex().getSelectables() ) {
+ for ( var selectable: getIndex().getSelectables() ) {
if ( selectable.isFormula() || !getCollectionTable().containsColumn( (Column) selectable ) ) {
indexIsPartOfElement = true;
}
}
if ( indexIsPartOfElement ) {
//if it is part of the element, use the element columns in the PK
- pk.addColumns( getElement() );
+ primaryKey.addColumns( getElement() );
}
else {
- pk.addColumns( getIndex() );
+ primaryKey.addColumns( getIndex() );
}
- getCollectionTable().setPrimaryKey(pk);
+ getCollectionTable().setPrimaryKey( primaryKey );
}
// else {
// don't create a unique key, 'cos some
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Join.java b/hibernate-core/src/main/java/org/hibernate/mapping/Join.java
index f9f4a4df32b1..c6d8513e02d5 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Join.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Join.java
@@ -114,7 +114,7 @@ public void disableForeignKeyCreation() {
}
public void createForeignKey() {
- final ForeignKey foreignKey = getKey().createForeignKeyOfEntity( persistentClass.getEntityName() );
+ final var foreignKey = getKey().createForeignKeyOfEntity( persistentClass.getEntityName() );
if ( disableForeignKeyCreation ) {
foreignKey.disableCreation();
}
@@ -122,10 +122,9 @@ public void createForeignKey() {
public void createPrimaryKey() {
//Primary key constraint
- PrimaryKey primaryKey = new PrimaryKey( table );
+ final var primaryKey = new PrimaryKey( table );
primaryKey.setName( PK_ALIAS.toAliasString( table.getName() ) );
table.setPrimaryKey(primaryKey);
-
primaryKey.addColumns( getKey() );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/JoinedSubclass.java b/hibernate-core/src/main/java/org/hibernate/mapping/JoinedSubclass.java
index a11a724b9901..2a7b9d147ebd 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/JoinedSubclass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/JoinedSubclass.java
@@ -44,7 +44,7 @@ public void setKey(KeyValue key) {
}
public void validate(Metadata mapping) throws MappingException {
- super.validate(mapping);
+ super.validate( mapping );
if ( key != null && !key.isValid( mapping ) ) {
throw new MappingException(
"subclass key mapping has wrong number of columns: " +
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/ManyToOne.java b/hibernate-core/src/main/java/org/hibernate/mapping/ManyToOne.java
index 6c39a293cdd4..af73c108a036 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/ManyToOne.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/ManyToOne.java
@@ -79,12 +79,12 @@ public void createPropertyRefConstraints(Map persistent
final String referencedEntityName = getReferencedEntityName();
final String referencedPropertyName = getReferencedPropertyName();
- final PersistentClass referencedClass = persistentClasses.get( referencedEntityName );
+ final var referencedClass = persistentClasses.get( referencedEntityName );
if ( referencedClass == null ) {
throw new MappingException( "Referenced entity '" + referencedEntityName + "' does not exist" );
}
- final Property property = referencedClass.getReferencedProperty( referencedPropertyName );
+ final var property = referencedClass.getReferencedProperty( referencedPropertyName );
if ( property==null ) {
throw new MappingException( "Referenced entity '" + referencedEntityName
+ "' has no property named '" + referencedPropertyName + "'" );
@@ -96,7 +96,7 @@ public void createPropertyRefConstraints(Map persistent
}
// todo : if "none" another option is to create the ForeignKey object still but to set its #disableCreation flag
if ( isForeignKeyEnabled() && !hasFormula() ) {
- final ForeignKey foreignKey = getTable().createForeignKey(
+ final var foreignKey = getTable().createForeignKey(
getForeignKeyName(),
getConstraintColumns(),
getType().getAssociatedEntityName(),
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 8f9dfacf0a4c..19b15a20f35e 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/MappedSuperclass.java
@@ -71,7 +71,7 @@ public void addDeclaredProperty(Property p) {
//Do not add duplicate properties
//TODO is it efficient enough?
String name = p.getName();
- for (Property declaredProperty : declaredProperties) {
+ for ( var declaredProperty : declaredProperties ) {
if ( name.equals( declaredProperty.getName() ) ) {
return;
}
@@ -164,7 +164,7 @@ public void setDeclaredIdentifierMapper(Component identifierMapper) {
* @return {@code true} if a property with that name exists; {@code false} if not
*/
public boolean hasProperty(String name) {
- for ( Property property : getDeclaredProperties() ) {
+ for ( var property : getDeclaredProperties() ) {
if ( property.getName().equals( name ) ) {
return true;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java b/hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java
index a2f8ca349ae1..d74059fbae88 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/MappingHelper.java
@@ -47,14 +47,15 @@ private static ManagedBean extends UserCollectionType> createSharedUserTypeBea
Class extends UserCollectionType> userCollectionTypeClass,
Map parameters,
BootstrapContext bootstrapContext) {
- final ManagedBean extends UserCollectionType> managedBean =
- bootstrapContext.getManagedBeanRegistry().getBean( userCollectionTypeClass );
+ final var managedBean =
+ bootstrapContext.getManagedBeanRegistry()
+ .getBean( userCollectionTypeClass );
if ( isNotEmpty( parameters ) ) {
if ( ParameterizedType.class.isAssignableFrom( managedBean.getBeanClass() ) ) {
// create a copy of the parameters and create a bean wrapper to delay injecting
// the parameters, thereby delaying the need to resolve the instance from the
// wrapped bean
- final Properties copy = new Properties();
+ final var copy = new Properties();
copy.putAll( parameters );
return new DelayedParameterizedTypeBean<>( managedBean, copy );
}
@@ -84,12 +85,12 @@ private static ManagedBean createLocalUserTypeBean(
String role,
Class extends UserCollectionType> implementation,
Map parameters) {
- final UserCollectionType userCollectionType =
+ final var userCollectionType =
FallbackBeanInstanceProducer.INSTANCE.produceBeanInstance( implementation );
if ( isNotEmpty( parameters ) ) {
// CollectionType declared parameters - inject them
if ( userCollectionType instanceof ParameterizedType parameterizedType ) {
- final Properties properties = new Properties();
+ final var properties = new Properties();
properties.putAll( parameters );
parameterizedType.setParameterValues( properties );
}
@@ -104,7 +105,7 @@ public static void checkPropertyColumnDuplication(
Set distinctColumns,
List properties,
String owner) throws MappingException {
- for ( Property prop : properties ) {
+ for ( var prop : properties ) {
if ( prop.isUpdatable() || prop.isInsertable() ) {
prop.getValue().checkColumnDuplication( distinctColumns, owner );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/OneToOne.java b/hibernate-core/src/main/java/org/hibernate/mapping/OneToOne.java
index 0ad3291093bf..22b99da2bbe5 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/OneToOne.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/OneToOne.java
@@ -100,19 +100,13 @@ public void createUniqueKey(MetadataBuildingContext context) {
@Override
public List getVirtualSelectables() {
- final List selectables = super.getVirtualSelectables();
- if ( selectables.isEmpty() ) {
- return identifier.getSelectables();
- }
- return selectables;
+ final var selectables = super.getVirtualSelectables();
+ return selectables.isEmpty() ? identifier.getSelectables() : selectables;
}
public List getConstraintColumns() {
- final List columns = super.getColumns();
- if ( columns.isEmpty() ) {
- return identifier.getColumns();
- }
- return columns;
+ final var columns = super.getColumns();
+ return columns.isEmpty() ? identifier.getColumns() : columns;
}
/**
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 39f107d5b98d..cc6ca2db14ed 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/PersistentClass.java
@@ -238,7 +238,7 @@ public boolean hasSubclasses() {
public int getSubclassSpan() {
int span = subclasses.size();
- for ( Subclass subclass : subclasses ) {
+ for ( var subclass : subclasses ) {
span += subclass.getSubclassSpan();
}
return span;
@@ -261,7 +261,7 @@ public List getSubclasses() {
public List getSubclassClosure() {
final ArrayList> lists = new ArrayList<>();
lists.add( List.of( this ) );
- for ( Subclass subclass : getSubclasses() ) {
+ for ( var subclass : getSubclasses() ) {
lists.add( subclass.getSubclassClosure() );
}
return new JoinedList<>( lists );
@@ -420,18 +420,18 @@ public void setEntityName(String entityName) {
public void createPrimaryKey() {
//Primary key constraint
- final Table table = getTable();
- final PrimaryKey pk = new PrimaryKey( table );
- pk.setName( PK_ALIAS.toAliasString( table.getName() ) );
- pk.addColumns( getKey() );
+ final var table = getTable();
+ final var primaryKey = new PrimaryKey( table );
+ primaryKey.setName( PK_ALIAS.toAliasString( table.getName() ) );
+ primaryKey.addColumns( getKey() );
if ( addPartitionKeyToPrimaryKey() ) {
- for ( Property property : getProperties() ) {
+ for ( var property : getProperties() ) {
if ( property.getValue().isPartitionKey() ) {
- pk.addColumns( property.getValue() );
+ primaryKey.addColumns( property.getValue() );
}
}
}
- table.setPrimaryKey( pk );
+ table.setPrimaryKey( primaryKey );
}
private boolean addPartitionKeyToPrimaryKey() {
@@ -507,10 +507,10 @@ public Property getRecursiveProperty(String propertyPath) throws MappingExceptio
private Property getRecursiveProperty(String propertyPath, List properties) throws MappingException {
Property property = null;
- StringTokenizer st = new StringTokenizer( propertyPath, ".", false );
+ var tokens = new StringTokenizer( propertyPath, ".", false );
try {
- while ( st.hasMoreElements() ) {
- final String element = (String) st.nextElement();
+ while ( tokens.hasMoreElements() ) {
+ final String element = (String) tokens.nextElement();
if ( property == null ) {
Property identifierProperty = getIdentifierProperty();
if ( identifierProperty != null && identifierProperty.getName().equals( element ) ) {
@@ -552,7 +552,7 @@ else if ( identifierProperty == null && getIdentifierMapper() != null ) {
private Property getProperty(String propertyName, List properties) throws MappingException {
final String root = root( propertyName );
- for ( Property property : properties ) {
+ for ( var property : properties ) {
if ( property.getName().equals( root )
|| ( property instanceof Backref || property instanceof IndexBackref )
&& property.getName().equals( propertyName ) ) {
@@ -564,14 +564,14 @@ private Property getProperty(String propertyName, List properties) thr
@Override
public Property getProperty(String propertyName) throws MappingException {
- final Property identifierProperty = getIdentifierProperty();
+ final var identifierProperty = getIdentifierProperty();
if ( identifierProperty != null
&& identifierProperty.getName().equals( root( propertyName ) ) ) {
return identifierProperty;
}
else {
List closure = getPropertyClosure();
- final Component identifierMapper = getIdentifierMapper();
+ final var identifierMapper = getIdentifierMapper();
if ( identifierMapper != null ) {
closure = new JoinedList<>( identifierMapper.getProperties(), closure );
}
@@ -587,12 +587,12 @@ public Property getProperty(String propertyName) throws MappingException {
* @return {@code true} if a property with that name exists; {@code false} if not
*/
public boolean hasProperty(String name) {
- final Property identifierProperty = getIdentifierProperty();
+ final var identifierProperty = getIdentifierProperty();
if ( identifierProperty != null && identifierProperty.getName().equals( name ) ) {
return true;
}
else {
- for ( Property property : getPropertyClosure() ) {
+ for ( var property : getPropertyClosure() ) {
if ( property.getName().equals( name ) ) {
return true;
}
@@ -639,7 +639,7 @@ public void setOptimisticLockStyle(OptimisticLockStyle optimisticLockStyle) {
}
public void validate(Metadata mapping) throws MappingException {
- for ( Property prop : getProperties() ) {
+ for ( var prop : getProperties() ) {
if ( !prop.isValid( mapping ) ) {
final Type type = prop.getType();
final int actualColumns = prop.getColumnSpan();
@@ -658,7 +658,7 @@ public void validate(Metadata mapping) throws MappingException {
private void checkPropertyDuplication() throws MappingException {
final HashSet names = new HashSet<>();
- for ( Property property : getProperties() ) {
+ for ( var property : getProperties() ) {
if ( !names.add( property.getName() ) ) {
throw new MappingException( "Duplicate property mapping of " + property.getName() + " found in " + getEntityName() );
}
@@ -711,7 +711,7 @@ public int getJoinClosureSpan() {
public int getPropertyClosureSpan() {
int span = properties.size();
- for ( Join join : joins ) {
+ for ( var join : joins ) {
span += join.getPropertySpan();
}
return span;
@@ -719,7 +719,7 @@ public int getPropertyClosureSpan() {
public int getJoinNumber(Property prop) {
int result = 1;
- for ( Join join : getSubclassJoinClosure() ) {
+ for ( var join : getSubclassJoinClosure() ) {
if ( join.containsProperty( prop ) ) {
return result;
}
@@ -744,7 +744,7 @@ public int getJoinNumber(Property prop) {
public List getProperties() {
final ArrayList> list = new ArrayList<>();
list.add( properties );
- for ( Join join : joins ) {
+ for ( var join : joins ) {
list.add( join.getProperties() );
}
return new JoinedList<>( list );
@@ -872,7 +872,7 @@ protected void checkColumnDuplication() {
getRootClass().getSoftDeleteColumn().getValue().checkColumnDuplication( cols, owner );
}
checkPropertyColumnDuplication( cols, getNonDuplicatedProperties(), owner );
- for ( Join join : getJoins() ) {
+ for ( var join : getJoins() ) {
cols.clear();
join.getKey().checkColumnDuplication( cols, owner );
checkPropertyColumnDuplication( cols, join.getProperties(), owner );
@@ -906,8 +906,8 @@ public boolean hasCollectionNotReferencingPK() {
}
private boolean hasCollectionNotReferencingPK(Collection properties) {
- for ( Property property : properties ) {
- final Value value = property.getValue();
+ for ( var property : properties ) {
+ final var value = property.getValue();
if ( value instanceof Component component ) {
if ( hasCollectionNotReferencingPK( component.getProperties() ) ) {
return true;
@@ -926,8 +926,8 @@ public boolean hasPartitionedSelectionMapping() {
if ( getSuperclass() != null && getSuperclass().hasPartitionedSelectionMapping() ) {
return true;
}
- for ( Property property : getProperties() ) {
- final Value value = property.getValue();
+ for ( var property : getProperties() ) {
+ final var value = property.getValue();
if ( value instanceof BasicValue basicValue && basicValue.isPartitionKey() ) {
return true;
}
@@ -979,9 +979,9 @@ public boolean hasNaturalId() {
}
private boolean determineIfNaturalIdDefined() {
- final List props = getRootClass().getProperties();
- for ( Property p : props ) {
- if ( p.isNaturalIdentifier() ) {
+ final List properties = getRootClass().getProperties();
+ for ( var property : properties ) {
+ if ( property.isNaturalIdentifier() ) {
return true;
}
}
@@ -992,15 +992,15 @@ private boolean determineIfNaturalIdDefined() {
public List getDeclaredProperties() {
final ArrayList> lists = new ArrayList<>();
lists.add( declaredProperties );
- for ( Join join : joins ) {
+ for ( var join : joins ) {
lists.add( join.getDeclaredProperties() );
}
return new JoinedList<>( lists );
}
- public void addMappedSuperclassProperty(Property p) {
- properties.add( p );
- p.setPersistentClass( this );
+ public void addMappedSuperclassProperty(Property property) {
+ properties.add( property );
+ property.setPersistentClass( this );
}
public MappedSuperclass getSuperMappedSuperclass() {
@@ -1012,7 +1012,7 @@ public void setSuperMappedSuperclass(MappedSuperclass superMappedSuperclass) {
}
public void assignCheckConstraintsToTable(Dialect dialect, TypeConfiguration types) {
- for ( CheckConstraint checkConstraint : checkConstraints ) {
+ for ( var checkConstraint : checkConstraints ) {
container( collectColumnNames( checkConstraint.getConstraint(), dialect, types ) )
.getTable().addCheck( checkConstraint );
}
@@ -1023,16 +1023,16 @@ public void prepareForMappingModel(RuntimeModelCreationContext context) {
if ( !joins.isEmpty() ) {
// we need to deal with references to secondary tables
// in SQL formulas
- final Dialect dialect = context.getDialect();
- final TypeConfiguration types = context.getTypeConfiguration();
+ final var dialect = context.getDialect();
+ final var types = context.getTypeConfiguration();
// now, move @Formulas to the correct AttributeContainers
//TODO: skip this step for hbm.xml
- for ( Property property : new ArrayList<>( properties ) ) {
- for ( Selectable selectable : property.getSelectables() ) {
+ for ( var property : new ArrayList<>( properties ) ) {
+ for ( var selectable : property.getSelectables() ) {
if ( selectable.isFormula() && properties.contains( property ) ) {
- final Formula formula = (Formula) selectable;
- final AttributeContainer container =
+ final var formula = (Formula) selectable;
+ final var container =
container( collectColumnNames( formula.getTemplate( dialect, types ) ) );
if ( !container.contains( property ) ) {
properties.remove( property );
@@ -1047,7 +1047,7 @@ public void prepareForMappingModel(RuntimeModelCreationContext context) {
}
private AttributeContainer container(List constrainedColumnNames) {
- long matches = matchesInTable( constrainedColumnNames, getTable() );
+ final long matches = matchesInTable( constrainedColumnNames, getTable() );
if ( matches == constrainedColumnNames.size() ) {
// perfect, all columns matched in the primary table
return this;
@@ -1056,7 +1056,7 @@ private AttributeContainer container(List constrainedColumnNames) {
// go searching for a secondary table which better matches
AttributeContainer result = this;
long max = matches;
- for ( Join join : getJoins() ) {
+ for ( var join : getJoins() ) {
long secondaryMatches = matchesInTable( constrainedColumnNames, join.getTable() );
if ( secondaryMatches > max ) {
result = join;
@@ -1094,7 +1094,7 @@ public Table findTable(String name) {
if ( getTable().getName().equals( name ) ) {
return getTable();
}
- final Join secondaryTable = findSecondaryTable( name );
+ final var secondaryTable = findSecondaryTable( name );
if ( secondaryTable != null ) {
return secondaryTable.getTable();
}
@@ -1103,7 +1103,7 @@ public Table findTable(String name) {
@Override
public Table getTable(String name) {
- final Table table = findTable( name );
+ final var table = findTable( name );
if ( table == null ) {
throw new MappingException( "Could not locate Table : " + name );
}
@@ -1113,7 +1113,7 @@ public Table getTable(String name) {
@Override
public Join findSecondaryTable(String name) {
for ( int i = 0; i < joins.size(); i++ ) {
- final Join join = joins.get( i );
+ final var join = joins.get( i );
if ( join.getTable().getNameIdentifier().matches( name ) ) {
return join;
}
@@ -1123,7 +1123,7 @@ public Join findSecondaryTable(String name) {
@Override
public Join getSecondaryTable(String name) {
- final Join secondaryTable = findSecondaryTable( name );
+ final var secondaryTable = findSecondaryTable( name );
if ( secondaryTable == null ) {
throw new MappingException( "Could not locate secondary Table : " + name );
}
@@ -1132,7 +1132,7 @@ public Join getSecondaryTable(String name) {
@Override
public IdentifiableTypeClass getSuperType() {
- final PersistentClass superPersistentClass = getSuperclass();
+ final var superPersistentClass = getSuperclass();
if ( superPersistentClass != null ) {
return superPersistentClass;
}
@@ -1146,17 +1146,18 @@ public List getSubTypes() {
@Override
public void applyProperty(Property property) {
- if ( property.getValue().getTable().equals( getImplicitTable() ) ) {
+ final var table = property.getValue().getTable();
+ if ( table.equals( getImplicitTable() ) ) {
addProperty( property );
}
else {
- final Join secondaryTable = getSecondaryTable( property.getValue().getTable().getName() );
+ final var secondaryTable = getSecondaryTable( table.getName() );
secondaryTable.addProperty( property );
}
}
private boolean containsColumn(Column column) {
- for ( Property declaredProperty : declaredProperties ) {
+ for ( var declaredProperty : declaredProperties ) {
if ( declaredProperty.getSelectables().contains( column ) ) {
return true;
}
@@ -1167,7 +1168,7 @@ private boolean containsColumn(Column column) {
@Internal
public boolean isDefinedOnMultipleSubclasses(Column column) {
PersistentClass declaringType = null;
- for ( PersistentClass persistentClass : getSubclassClosure() ) {
+ for ( var persistentClass : getSubclassClosure() ) {
if ( persistentClass.containsColumn( column ) ) {
if ( declaringType != null && declaringType != persistentClass ) {
return true;
@@ -1182,16 +1183,18 @@ public boolean isDefinedOnMultipleSubclasses(Column column) {
@Internal
public PersistentClass getSuperPersistentClass() {
- return getSuperclass() != null ? getSuperclass() : getSuperPersistentClass( getSuperMappedSuperclass() );
+ final var superclass = getSuperclass();
+ return superclass == null
+ ? getSuperPersistentClass( getSuperMappedSuperclass() )
+ : superclass;
}
private static PersistentClass getSuperPersistentClass(MappedSuperclass mappedSuperclass) {
if ( mappedSuperclass != null ) {
- final PersistentClass superClass = mappedSuperclass.getSuperPersistentClass();
- if ( superClass != null ) {
- return superClass;
- }
- return getSuperPersistentClass( mappedSuperclass.getSuperMappedSuperclass() );
+ final var superclass = mappedSuperclass.getSuperPersistentClass();
+ return superclass == null
+ ? getSuperPersistentClass( mappedSuperclass.getSuperMappedSuperclass() )
+ : superclass;
}
return null;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java b/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java
index 12db9bbd96f9..837e416cd17f 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java
@@ -33,7 +33,7 @@ public PrimaryKey() {
@Override
public void addColumn(Column column) {
// force primary key columns to not-null
- for ( Column next : getTable().getColumns() ) {
+ for ( var next : getTable().getColumns() ) {
if ( next.getCanonicalName().equals( column.getCanonicalName() ) ) {
next.setNullable( false );
}
@@ -47,11 +47,11 @@ public String getExportIdentifier() {
}
public List getColumnsInOriginalOrder() {
- final List columns = getColumns();
+ final var columns = getColumns();
if ( originalOrder == null ) {
return columns;
}
- final Column[] columnsInOriginalOrder = new Column[columns.size()];
+ final var columnsInOriginalOrder = new Column[columns.size()];
for ( int i = 0; i < columnsInOriginalOrder.length; i++ ) {
columnsInOriginalOrder[originalOrder[i]] = columns.get( i );
}
@@ -68,20 +68,21 @@ public UniqueKey getOrderingUniqueKey() {
@Internal
public void reorderColumns(List reorderedColumns) {
- final List columns = getColumns();
+ final var columns = getColumns();
if ( originalOrder != null ) {
assert columns.equals( reorderedColumns );
return;
}
- assert columns.size() == reorderedColumns.size() && columns.containsAll( reorderedColumns );
+ assert columns.size() == reorderedColumns.size()
+ && columns.containsAll( reorderedColumns );
originalOrder = new int[columns.size()];
- final UniqueKey orderingUniqueKey = getOrderingUniqueKey();
- final List newColumns =
+ final var orderingUniqueKey = getOrderingUniqueKey();
+ final var newColumns =
orderingUniqueKey != null
? orderingUniqueKey.getColumns()
: reorderedColumns;
for ( int i = 0; i < newColumns.size(); i++ ) {
- final Column reorderedColumn = newColumns.get( i );
+ final var reorderedColumn = newColumns.get( i );
originalOrder[i] = columns.indexOf( reorderedColumn );
}
columns.clear();
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 7cb73fedd726..edbd4f0887cc 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Property.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Property.java
@@ -137,7 +137,7 @@ public void resetUpdateable(boolean updateable) {
public void resetOptional(boolean optional) {
setOptional( optional );
- for ( Selectable selectable: getValue().getSelectables() ) {
+ for ( var selectable: getValue().getSelectables() ) {
if ( selectable instanceof Column column ) {
column.setNullable( optional );
}
@@ -157,7 +157,7 @@ else if ( type instanceof ComponentType componentType ) {
return getCompositeCascadeStyle( componentType, cascade );
}
else if ( type instanceof CollectionType ) {
- final Collection collection = (Collection) value;
+ final var collection = (Collection) value;
return getCollectionCascadeStyle( collection.getElement().getType(), cascade );
}
else {
@@ -533,7 +533,7 @@ public Generator createGenerator(RuntimeModelCreationContext context) {
}
public Property copy() {
- final Property property =
+ final var property =
this instanceof SyntheticProperty
? new SyntheticProperty()
: new Property();
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/RootClass.java b/hibernate-core/src/main/java/org/hibernate/mapping/RootClass.java
index b2cdf91e62d2..e44a6aa6f77a 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/RootClass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/RootClass.java
@@ -297,7 +297,7 @@ private void checkTableDuplication() {
tables.add( getTable() );
for ( Subclass subclass : getSubclasses() ) {
if ( !(subclass instanceof SingleTableSubclass) ) {
- final Table table = subclass.getTable();
+ final var table = subclass.getTable();
if ( !tables.add( table ) ) {
// we encountered a duplicate table mapping
if ( getDiscriminator() == null ) {
@@ -328,7 +328,7 @@ private void checkTableDuplication() {
private void checkCompositeIdentifier() {
if ( getIdentifier() instanceof Component id
&& !id.isDynamic() ) {
- final Class> idClass = id.getComponentClass();
+ final var idClass = id.getComponentClass();
if ( idClass != null ) {
if ( !overridesEquals( idClass ) ) {
CORE_LOGGER.compositeIdClassDoesNotOverrideEquals( idClass.getName() );
@@ -386,7 +386,7 @@ public Set getSynchronizedTables() {
public Set getIdentityTables() {
final Set tables = new HashSet<>();
- for ( PersistentClass clazz : getSubclassClosure() ) {
+ for ( var clazz : getSubclassClosure() ) {
if ( clazz.isAbstract() == null || !clazz.isAbstract() ) {
tables.add( clazz.getIdentityTable() );
}
@@ -396,8 +396,8 @@ public Set getIdentityTables() {
@Override
public void enableSoftDelete(Column indicatorColumn, SoftDeleteType strategy) {
- this.softDeleteColumn = indicatorColumn;
- this.softDeleteStrategy = strategy;
+ softDeleteColumn = indicatorColumn;
+ softDeleteStrategy = strategy;
}
@Override
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 dbdacd10c792..ddf9a042bc1e 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Set.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Set.java
@@ -78,23 +78,23 @@ else if ( hasOrder() ) {
void createPrimaryKey() {
if ( !isOneToMany() ) {
- final Table collectionTable = getCollectionTable();
- PrimaryKey pk = collectionTable.getPrimaryKey();
- if ( pk == null ) {
- pk = new PrimaryKey( getCollectionTable() );
- pk.addColumns( getKey() );
- for ( Selectable selectable : getElement().getSelectables() ) {
+ final var collectionTable = getCollectionTable();
+ var primaryKey = collectionTable.getPrimaryKey();
+ if ( primaryKey == null ) {
+ primaryKey = new PrimaryKey( getCollectionTable() );
+ primaryKey.addColumns( getKey() );
+ for ( var selectable : getElement().getSelectables() ) {
if ( selectable instanceof Column col ) {
if ( !col.isNullable() ) {
- pk.addColumn( col );
+ primaryKey.addColumn( col );
}
else {
return;
}
}
}
- if ( pk.getColumnSpan() != getKey().getColumnSpan() ) {
- collectionTable.setPrimaryKey( pk );
+ if ( primaryKey.getColumnSpan() != getKey().getColumnSpan() ) {
+ collectionTable.setPrimaryKey( primaryKey );
}
// else {
//for backward compatibility, allow a set with no not-null
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 8718b7599187..4055e102423e 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java
@@ -8,7 +8,6 @@
import java.lang.annotation.Annotation;
import java.sql.Types;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -19,6 +18,7 @@
import org.hibernate.FetchMode;
import org.hibernate.Internal;
import org.hibernate.MappingException;
+import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.type.TimeZoneStorageStrategy;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.boot.model.convert.internal.ConverterDescriptors;
@@ -45,8 +45,6 @@
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
-import org.hibernate.type.descriptor.jdbc.LobTypeMappings;
-import org.hibernate.type.descriptor.jdbc.NationalizedTypeMappings;
import org.hibernate.type.internal.ConvertedBasicTypeImpl;
import org.hibernate.type.internal.ParameterizedTypeImpl;
import org.hibernate.type.MappingContext;
@@ -64,6 +62,10 @@
import static org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass;
import static org.hibernate.internal.util.collections.ArrayHelper.toBooleanArray;
import static org.hibernate.mapping.MappingHelper.classForName;
+import static org.hibernate.models.spi.TypeDetails.Kind.PARAMETERIZED_TYPE;
+import static org.hibernate.type.descriptor.jdbc.LobTypeMappings.getLobCodeTypeMapping;
+import static org.hibernate.type.descriptor.jdbc.LobTypeMappings.isMappedToKnownLobCode;
+import static org.hibernate.type.descriptor.jdbc.NationalizedTypeMappings.toNationalizedTypeCode;
/**
* A mapping model object that represents any value that maps to columns.
@@ -147,6 +149,10 @@ public MetadataBuildingContext getBuildingContext() {
return buildingContext;
}
+ BootstrapContext getBootstrapContext() {
+ return getBuildingContext().getBootstrapContext();
+ }
+
public MetadataImplementor getMetadata() {
return metadata;
}
@@ -161,7 +167,7 @@ public ServiceRegistry getServiceRegistry() {
}
public TypeConfiguration getTypeConfiguration() {
- return getBuildingContext().getBootstrapContext().getTypeConfiguration();
+ return getBootstrapContext().getTypeConfiguration();
}
public void setOnDeleteAction(OnDeleteAction onDeleteAction) {
@@ -220,12 +226,12 @@ protected void justAddFormula(Formula formula) {
public void sortColumns(int[] originalOrder) {
if ( columns.size() > 1 ) {
- final Selectable[] originalColumns = columns.toArray( new Selectable[0] );
+ final var originalColumns = columns.toArray( new Selectable[0] );
final boolean[] originalInsertability = toBooleanArray( insertability );
final boolean[] originalUpdatability = toBooleanArray( updatability );
for ( int i = 0; i < originalOrder.length; i++ ) {
final int originalIndex = originalOrder[i];
- final Selectable selectable = originalColumns[i];
+ final var selectable = originalColumns[i];
if ( selectable instanceof Column column ) {
column.setTypeIndex( originalIndex );
}
@@ -238,7 +244,7 @@ public void sortColumns(int[] originalOrder) {
@Override
public boolean hasFormula() {
- for ( Selectable selectable : getSelectables() ) {
+ for ( var selectable : getSelectables() ) {
if ( selectable instanceof Formula ) {
return true;
}
@@ -286,19 +292,18 @@ public void setTypeName(String typeName) {
void setAttributeConverterDescriptor(String typeName) {
final String converterClassName = typeName.substring( TYPE_NAME_PREFIX.length() );
- final MetadataBuildingContext context = getBuildingContext();
+ final var bootstrapContext = getBootstrapContext();
@SuppressWarnings("unchecked") // Completely safe
- final Class extends AttributeConverter,?>> clazz =
+ final var clazz =
(Class extends AttributeConverter,?>>)
- classForName( AttributeConverter.class, converterClassName,
- context.getBootstrapContext() );
+ classForName( AttributeConverter.class, converterClassName, bootstrapContext );
attributeConverterDescriptor =
ConverterDescriptors.of( clazz, null, false,
- context.getBootstrapContext().getClassmateContext() );
+ bootstrapContext.getClassmateContext() );
}
ClassLoaderService classLoaderService() {
- return getBuildingContext().getBootstrapContext().getClassLoaderService();
+ return getBootstrapContext().getClassLoaderService();
}
public void makeVersion() {
@@ -332,12 +337,12 @@ public void setTable(Table table) {
@Override
public void createForeignKey() throws MappingException {}
- public void createForeignKey(PersistentClass referencedEntity, AnnotatedJoinColumns joinColumns) throws MappingException {}
+ public void createForeignKey(PersistentClass referencedEntity, AnnotatedJoinColumns joinColumns) {}
@Override
public ForeignKey createForeignKeyOfEntity(String entityName) {
if ( isConstrained() ) {
- final ForeignKey foreignKey = table.createForeignKey(
+ final var foreignKey = table.createForeignKey(
getForeignKeyName(),
getConstraintColumns(),
entityName,
@@ -347,14 +352,15 @@ public ForeignKey createForeignKeyOfEntity(String entityName) {
foreignKey.setOnDeleteAction( onDeleteAction );
return foreignKey;
}
-
- return null;
+ else {
+ return null;
+ }
}
@Override
public ForeignKey createForeignKeyOfEntity(String entityName, List referencedColumns) {
if ( isConstrained() ) {
- final ForeignKey foreignKey = table.createForeignKey(
+ final var foreignKey = table.createForeignKey(
getForeignKeyName(),
getConstraintColumns(),
entityName,
@@ -403,7 +409,7 @@ public String getDefaultSchema() {
@Override
public SqlStringGenerationContext getSqlStringGenerationContext() {
- final Database database = buildingContext.getMetadataCollector().getDatabase();
+ final var database = buildingContext.getMetadataCollector().getDatabase();
return fromExplicit( database.getJdbcEnvironment(), database, getDefaultCatalog(), getDefaultSchema() );
}
} );
@@ -416,9 +422,8 @@ public Generator createGenerator(
Property property,
GeneratorSettings defaults) {
if ( customIdGeneratorCreator != null ) {
- final IdGeneratorCreationContext context =
- new IdGeneratorCreationContext( rootClass, property, defaults );
- final Generator generator = customIdGeneratorCreator.createGenerator( context );
+ final var context = new IdGeneratorCreationContext( rootClass, property, defaults );
+ final var generator = customIdGeneratorCreator.createGenerator( context );
if ( generator.allowAssignedIdentifiers() && nullValue == null ) {
setNullValueUndefined();
}
@@ -574,7 +579,7 @@ public void setAlternateUniqueKey(boolean unique) {
@Override
public boolean isNullable() {
- for ( Selectable selectable : getSelectables() ) {
+ for ( var selectable : getSelectables() ) {
if ( selectable instanceof Formula ) {
// if there are *any* formulas, then the Value overall is
// considered nullable
@@ -602,7 +607,7 @@ public boolean isValid(MappingContext mappingContext) throws MappingException {
return getColumnSpan() == getType().getColumnSpan( mappingContext );
}
- protected void setAttributeConverterDescriptor(ConverterDescriptor descriptor) {
+ protected void setAttributeConverterDescriptor(ConverterDescriptor,?> descriptor) {
this.attributeConverterDescriptor = descriptor;
}
@@ -651,35 +656,32 @@ protected ConverterDescriptor,?> getAttributeConverterDescriptor() {
@Override
public void setTypeUsingReflection(String className, String propertyName) throws MappingException {
- // NOTE : this is called as the last piece in setting SimpleValue type information, and implementations
- // rely on that fact, using it as a signal that all information it is going to get is defined at this point...
-
- if ( typeName != null ) {
- // assume either (a) explicit type was specified or (b) determine was already performed
- return;
- }
-
- if ( type != null ) {
- return;
- }
-
- if ( attributeConverterDescriptor == null ) {
- // this is here to work like legacy. This should change when we integrate with metamodel to
- // look for JdbcType and JavaType individually and create the BasicType (well, really
- // keep a registry of [JdbcType,JavaType] -> BasicType...)
- if ( className == null ) {
- throw new MappingException( "Attribute types for a dynamic entity must be explicitly specified: " + propertyName );
+ // NOTE: this is called as the last piece in setting SimpleValue type information,
+ // and implementations rely on that fact, using it as a signal that all
+ // the information it is going to get is already specified at this point
+ if ( typeName == null && type == null ) {
+ if ( attributeConverterDescriptor == null ) {
+ // This is here to work like legacy. This should change when we integrate with metamodel
+ // to look for JdbcType and JavaType individually and create the BasicType (well, really
+ // keep a registry of [JdbcType,JavaType] -> BasicType...)
+ if ( className == null ) {
+ throw new MappingException(
+ "Attribute types for a dynamic entity must be explicitly specified: " + propertyName );
+ }
+ typeName = getClass( className, propertyName ).getName();
+ // 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) JdbcType, a (2) JavaType and dynamically building a BasicType
+ // combining them.
+ }
+ else {
+ // we had an AttributeConverter
+ type = buildAttributeConverterTypeAdapter();
}
- typeName = getClass( className, propertyName ).getName();
- // 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) JdbcType, a (2) JavaType and dynamically building a BasicType
- // combining them.
- return;
}
-
- // we had an AttributeConverter...
- type = buildAttributeConverterTypeAdapter();
+ // otherwise assume either
+ // (a) explicit type was specified or
+ // (b) determine was already performed
}
private Class> getClass(String className, String propertyName) {
@@ -723,7 +725,7 @@ private Type buildAttributeConverterTypeAdapter() {
new JpaAttributeConverterCreationContext() {
@Override
public ManagedBeanRegistry getManagedBeanRegistry() {
- return getBuildingContext().getBootstrapContext().getManagedBeanRegistry();
+ return getBootstrapContext().getManagedBeanRegistry();
}
@Override
@@ -736,8 +738,8 @@ public TypeConfiguration getTypeConfiguration() {
private Type buildAttributeConverterTypeAdapter(
JpaAttributeConverter jpaAttributeConverter) {
- final JavaType domainJavaType = jpaAttributeConverter.getDomainJavaType();
- final JavaType> relationalJavaType = jpaAttributeConverter.getRelationalJavaType();
+ final var domainJavaType = jpaAttributeConverter.getDomainJavaType();
+ final var relationalJavaType = jpaAttributeConverter.getRelationalJavaType();
// build the SqlTypeDescriptor adapter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Going back to the illustration, this should be a SqlTypeDescriptor that handles the Integer <-> String
@@ -745,7 +747,7 @@ private Type buildAttributeConverterTypeAdapter(
// corresponding to the AttributeConverter's declared "databaseColumnJavaType" (how we read that value out
// of ResultSets). See JdbcTypeJavaClassMappings for details. Again, given example, this should return
// VARCHAR/CHAR
- final JdbcType recommendedJdbcType = relationalJavaType.getRecommendedJdbcType(
+ final var recommendedJdbcType = relationalJavaType.getRecommendedJdbcType(
// todo (6.0) : handle the other JdbcRecommendedSqlTypeMappingContext methods
new JdbcTypeIndicators() {
@Override
@@ -764,10 +766,28 @@ public Dialect getDialect() {
}
}
);
- int jdbcTypeCode = recommendedJdbcType.getDdlTypeCode();
+
+ // todo : cache the AttributeConverterTypeAdapter in case that AttributeConverter is applied multiple times.
+ return new ConvertedBasicTypeImpl<>(
+ TYPE_NAME_PREFIX
+ + jpaAttributeConverter.getConverterJavaType().getTypeName(),
+ String.format(
+ "BasicType adapter for AttributeConverter<%s,%s>",
+ domainJavaType.getTypeName(),
+ relationalJavaType.getTypeName()
+ ),
+ metadata.getTypeConfiguration().getJdbcTypeRegistry()
+ .getDescriptor( jdbcTypeCode( recommendedJdbcType, domainJavaType ) ),
+ jpaAttributeConverter
+ );
+ }
+
+ private int jdbcTypeCode(JdbcType recommendedJdbcType, JavaType domainJavaType) {
+ final int recommendedDdlTypeCode = recommendedJdbcType.getDdlTypeCode();
+ final int jdbcTypeCode;
if ( isLob() ) {
- if ( LobTypeMappings.isMappedToKnownLobCode( jdbcTypeCode ) ) {
- jdbcTypeCode = LobTypeMappings.getLobCodeTypeMapping( jdbcTypeCode );
+ if ( isMappedToKnownLobCode( recommendedDdlTypeCode ) ) {
+ jdbcTypeCode = getLobCodeTypeMapping( recommendedDdlTypeCode );
}
else {
if ( Serializable.class.isAssignableFrom( domainJavaType.getJavaTypeClass() ) ) {
@@ -778,30 +798,17 @@ public Dialect getDialect() {
String.format(
Locale.ROOT,
"JDBC type-code [%s (%s)] not known to have a corresponding LOB equivalent, and Java type is not Serializable (to use BLOB)",
- jdbcTypeCode,
- JdbcTypeNameMapper.getTypeName( jdbcTypeCode )
+ recommendedDdlTypeCode,
+ JdbcTypeNameMapper.getTypeName( recommendedDdlTypeCode )
)
);
}
}
}
- if ( isNationalized() ) {
- jdbcTypeCode = NationalizedTypeMappings.toNationalizedTypeCode( jdbcTypeCode );
+ else {
+ jdbcTypeCode = recommendedDdlTypeCode;
}
-
-
- // todo : cache the AttributeConverterTypeAdapter in case that AttributeConverter is applied multiple times.
- return new ConvertedBasicTypeImpl<>(
- TYPE_NAME_PREFIX
- + jpaAttributeConverter.getConverterJavaType().getTypeName(),
- String.format(
- "BasicType adapter for AttributeConverter<%s,%s>",
- domainJavaType.getTypeName(),
- relationalJavaType.getTypeName()
- ),
- metadata.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( jdbcTypeCode ),
- jpaAttributeConverter
- );
+ return isNationalized() ? toNationalizedTypeCode( jdbcTypeCode ) : jdbcTypeCode;
}
public boolean isTypeSpecified() {
@@ -814,7 +821,7 @@ public void setTypeParameters(Properties parameterMap) {
public void setTypeParameters(Map parameters) {
if ( parameters != null ) {
- final Properties properties = new Properties();
+ final var properties = new Properties();
properties.putAll( parameters );
setTypeParameters( properties );
}
@@ -936,7 +943,7 @@ public void setJpaAttributeConverterDescriptor(ConverterDescriptor,?> descript
private static final Annotation[] NO_ANNOTATIONS = new Annotation[0];
private static Annotation[] getAnnotations(MemberDetails memberDetails) {
- final Collection extends Annotation> directAnnotationUsages =
+ final var directAnnotationUsages =
memberDetails == null ? null
: memberDetails.getDirectAnnotationUsages();
return directAnnotationUsages == null ? NO_ANNOTATIONS
@@ -947,15 +954,13 @@ protected ParameterType createParameterType() {
try {
final String[] columnNames = new String[ columns.size() ];
final Long[] columnLengths = new Long[ columns.size() ];
-
for ( int i = 0; i < columns.size(); i++ ) {
- final Selectable selectable = columns.get(i);
+ final var selectable = columns.get(i);
if ( selectable instanceof Column column ) {
columnNames[i] = column.getName();
columnLengths[i] = column.getLength();
}
}
-
// todo : not sure this works for handling @MapKeyEnumerated
return createParameterType( columnNames, columnLengths );
}
@@ -965,7 +970,7 @@ protected ParameterType createParameterType() {
}
private ParameterType createParameterType(String[] columnNames, Long[] columnLengths) {
- final MemberDetails attribute = (MemberDetails) typeParameters.get( DynamicParameterizedType.XPROPERTY );
+ final var attribute = (MemberDetails) typeParameters.get( DynamicParameterizedType.XPROPERTY );
return new ParameterTypeImpl(
classLoaderService()
.classForTypeName( typeParameters.getProperty( DynamicParameterizedType.RETURNED_CLASS ) ),
@@ -1011,16 +1016,14 @@ private ParameterTypeImpl(
this.columns = columns;
this.columnLengths = columnLengths;
- if ( returnedTypeDetails != null ) {
- if ( returnedTypeDetails.getTypeKind() == TypeDetails.Kind.PARAMETERIZED_TYPE ) {
- this.returnedJavaType = ParameterizedTypeImpl.from( returnedTypeDetails.asParameterizedType() );
- }
- else {
- this.returnedJavaType = returnedTypeDetails.determineRawClass().toJavaClass();
- }
+ if ( returnedTypeDetails == null ) {
+ returnedJavaType = null;
}
else {
- this.returnedJavaType = null;
+ returnedJavaType =
+ returnedTypeDetails.getTypeKind() == PARAMETERIZED_TYPE
+ ? ParameterizedTypeImpl.from( returnedTypeDetails.asParameterizedType() )
+ : returnedTypeDetails.determineRawClass().toJavaClass();
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java b/hibernate-core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java
index aeb01a302c10..3bb266325230 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/SingleTableSubclass.java
@@ -9,7 +9,6 @@
import org.hibernate.MappingException;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.dialect.Dialect;
import org.hibernate.internal.util.collections.JoinedList;
import static org.hibernate.persister.entity.DiscriminatorHelper.getDiscriminatorSQLValue;
@@ -48,12 +47,12 @@ public void validate(Metadata mapping) throws MappingException {
@Override
public void createConstraints(MetadataBuildingContext context) {
if ( !isAbstract() ) {
- final Dialect dialect = context.getMetadataCollector().getDatabase().getDialect();
+ final var dialect = context.getMetadataCollector().getDatabase().getDialect();
if ( dialect.supportsTableCheck() ) {
- final Value discriminator = getDiscriminator();
- final List selectables = discriminator.getSelectables();
+ final var discriminator = getDiscriminator();
+ final var selectables = discriminator.getSelectables();
if ( selectables.size() == 1 ) {
- final StringBuilder check = new StringBuilder();
+ final var check = new StringBuilder();
check.append( selectables.get( 0 ).getText( dialect ) );
if ( isDiscriminatorValueNull() ) {
check.append( " is " );
@@ -71,9 +70,9 @@ else if ( isDiscriminatorValueNotNull() ) {
check.append( getDiscriminatorSQLValue( this, dialect ) )
.append( " or (" );
boolean first = true;
- for ( Property property : getNonDuplicatedProperties() ) {
+ for ( var property : getNonDuplicatedProperties() ) {
if ( !property.isComposite() && !property.isOptional() ) {
- for ( Selectable selectable : property.getSelectables() ) {
+ for ( var selectable : property.getSelectables() ) {
if ( selectable instanceof Column column && column.isNullable() ) {
if ( first ) {
first = false;
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 061794ce120c..06398fe1e870 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java
@@ -8,7 +8,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -139,7 +138,7 @@ public String getQualifiedName(SqlStringGenerationContext context) {
*/
@Deprecated
public static String qualify(String catalog, String schema, String table) {
- final StringBuilder qualifiedName = new StringBuilder();
+ final var qualifiedName = new StringBuilder();
if ( catalog != null ) {
qualifiedName.append( catalog ).append( '.' );
}
@@ -250,22 +249,18 @@ public Column getColumn(Column column) {
}
public Column getColumn(Identifier name) {
- if ( name == null ) {
- return null;
- }
- return columns.get( name.getCanonicalName() );
+ return name == null ? null
+ : columns.get( name.getCanonicalName() );
}
@Internal
public Column getColumn(InFlightMetadataCollector collector, String logicalName) {
- if ( name == null ) {
- return null;
- }
- return getColumn( new Column( collector.getPhysicalColumnName( this, logicalName ) ) );
+ return name == null ? null
+ : getColumn( new Column( collector.getPhysicalColumnName( this, logicalName ) ) );
}
public Column getColumn(int n) {
- final Iterator iter = columns.values().iterator();
+ final var iter = columns.values().iterator();
for ( int i = 0; i < n - 1; i++ ) {
iter.next();
}
@@ -273,11 +268,11 @@ public Column getColumn(int n) {
}
public void addColumn(Column column) {
- final Column old = getColumn( column );
- if ( old == null ) {
+ final var oldColumn = getColumn( column );
+ if ( oldColumn == null ) {
if ( primaryKey != null ) {
- for ( Column pkColumn : primaryKey.getColumns() ) {
- if ( pkColumn.getCanonicalName().equals( column.getCanonicalName() ) ) {
+ for ( var primaryKeyColumn : primaryKey.getColumns() ) {
+ if ( primaryKeyColumn.getCanonicalName().equals( column.getCanonicalName() ) ) {
column.setNullable( false );
if ( LOG.isTraceEnabled() ) {
LOG.tracef(
@@ -293,7 +288,7 @@ public void addColumn(Column column) {
column.uniqueInteger = columns.size();
}
else {
- column.uniqueInteger = old.uniqueInteger;
+ column.uniqueInteger = oldColumn.uniqueInteger;
}
}
@@ -377,9 +372,9 @@ public boolean isRedundantUniqueKey(UniqueKey uniqueKey) {
// Never remove explicit unique keys based on column matching
if ( !uniqueKey.isExplicit() ) {
- // condition 1 : check against other unique keys
- for ( UniqueKey otherUniqueKey : uniqueKeys.values() ) {
- // make sure it's not the same unique key
+ // condition 1: check against other unique keys
+ for ( var otherUniqueKey : uniqueKeys.values() ) {
+ // make sure it's a different unique key
if ( uniqueKey != otherUniqueKey
&& otherUniqueKey.getColumns().containsAll( uniqueKey.getColumns() )
&& uniqueKey.getColumns().containsAll( otherUniqueKey.getColumns() ) ) {
@@ -388,7 +383,7 @@ public boolean isRedundantUniqueKey(UniqueKey uniqueKey) {
}
}
- // condition 2 : check against pk
+ // condition 2: check against the primary key
if ( isSameAsPrimaryKeyColumns( uniqueKey ) ) {
primaryKey.setOrderingUniqueKey( uniqueKey );
return true;
@@ -468,7 +463,7 @@ public Index getIndex(String indexName) {
}
public Index addIndex(Index index) {
- final Index current = indexes.get( index.getName() );
+ final var current = indexes.get( index.getName() );
if ( current != null ) {
throw new MappingException( "Index " + index.getName() + " already exists" );
}
@@ -477,7 +472,7 @@ public Index addIndex(Index index) {
}
public UniqueKey addUniqueKey(UniqueKey uniqueKey) {
- final UniqueKey current = uniqueKeys.get( uniqueKey.getName() );
+ final var current = uniqueKeys.get( uniqueKey.getName() );
if ( current != null ) {
throw new MappingException( "UniqueKey " + uniqueKey.getName() + " already exists" );
}
@@ -552,8 +547,8 @@ public MetadataBuildingContext getBuildingContext() {
}
} )
.render( context.getMetadataCollector().getDatabase().getDialect() );
- final UniqueKey uniqueKey = getOrCreateUniqueKey( keyName );
- for ( Column keyColumn : keyColumns ) {
+ final var uniqueKey = getOrCreateUniqueKey( keyName );
+ for ( var keyColumn : keyColumns ) {
uniqueKey.addColumn( keyColumn );
}
}
@@ -592,7 +587,7 @@ public ForeignKey createForeignKey(
String keyDefinition,
String options,
List referencedColumns) {
- final ForeignKeyKey key = new ForeignKeyKey( keyColumns, referencedEntityName, referencedColumns );
+ final var key = new ForeignKeyKey( keyColumns, referencedEntityName, referencedColumns );
ForeignKey foreignKey = foreignKeys.get( key );
if ( foreignKey == null ) {
@@ -600,7 +595,7 @@ public ForeignKey createForeignKey(
foreignKey.setReferencedEntityName( referencedEntityName );
foreignKey.setKeyDefinition( keyDefinition );
foreignKey.setOptions( options );
- for ( Column keyColumn : keyColumns ) {
+ for ( var keyColumn : keyColumns ) {
foreignKey.addColumn( keyColumn );
}
@@ -609,8 +604,8 @@ public ForeignKey createForeignKey(
foreignKey.addReferencedColumns( referencedColumns );
}
- // NOTE : if the name is null, we will generate an implicit name during second pass processing
- // after we know the referenced table name (which might not be resolved yet).
+ // NOTE: if the name is null, we will generate an implicit name during second pass processing
+ // after we know the referenced table name (which might not be resolved yet).
foreignKey.setName( keyName );
foreignKeys.put( key, foreignKey );
@@ -631,7 +626,7 @@ private void checkPrimaryKeyUniqueKey() {
final var uniqueKeyEntries = uniqueKeys.entrySet().iterator();
while ( uniqueKeyEntries.hasNext() ) {
final var uniqueKeyEntry = uniqueKeyEntries.next();
- final UniqueKey uniqueKey = uniqueKeyEntry.getValue();
+ final var uniqueKey = uniqueKeyEntry.getValue();
if ( isSameAsPrimaryKeyColumns( uniqueKey ) ) {
primaryKey.setOrderingUniqueKey( uniqueKey );
uniqueKeyEntries.remove();
@@ -671,7 +666,7 @@ public void setRowId(String rowId) {
}
public String toString() {
- final StringBuilder string = new StringBuilder()
+ final var string = new StringBuilder()
.append( getClass().getSimpleName() )
.append( '(' );
if ( getCatalog() != null ) {
@@ -749,7 +744,7 @@ private String render(Identifier identifier) {
public void reorderColumns(List columns) {
assert this.columns.size() == columns.size() && this.columns.values().containsAll( columns );
this.columns.clear();
- for ( Column column : columns ) {
+ for ( var column : columns ) {
this.columns.put( column.getCanonicalName(), column );
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/ToOne.java b/hibernate-core/src/main/java/org/hibernate/mapping/ToOne.java
index 5bf7c6612608..4826d44f23cf 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/ToOne.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/ToOne.java
@@ -6,17 +6,15 @@
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
-import org.hibernate.boot.model.internal.AnnotatedJoinColumn;
import org.hibernate.boot.model.internal.AnnotatedJoinColumns;
-import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.type.EntityType;
import org.hibernate.type.MappingContext;
import java.util.Objects;
import static org.hibernate.boot.model.internal.BinderHelper.findReferencedColumnOwner;
+import static org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass;
/**
* A mapping model object representing an association where the target side has cardinality one.
@@ -93,8 +91,8 @@ public void setPropertyName(String propertyName) {
@Override
public void setTypeUsingReflection(String className, String propertyName) throws MappingException {
if ( referencedEntityName == null ) {
- final ClassLoaderService cls = getBuildingContext().getBootstrapContext().getClassLoaderService();
- referencedEntityName = ReflectHelper.reflectedPropertyClass( className, propertyName, cls ).getName();
+ final var classLoaderService = getBootstrapContext().getClassLoaderService();
+ referencedEntityName = reflectedPropertyClass( className, propertyName, classLoaderService ).getName();
}
}
@@ -171,11 +169,12 @@ public void setSorted(boolean sorted) {
@Override
public int[] sortProperties() {
- final PersistentClass entityBinding = getMetadata().getEntityBinding( referencedEntityName );
+ final var entityBinding = getMetadata().getEntityBinding( referencedEntityName );
if ( entityBinding != null ) {
- final Value value = referencedPropertyName == null
- ? entityBinding.getIdentifier()
- : entityBinding.getRecursiveProperty( referencedPropertyName ).getValue();
+ final var value =
+ referencedPropertyName == null
+ ? entityBinding.getIdentifier()
+ : entityBinding.getRecursiveProperty( referencedPropertyName ).getValue();
if ( value instanceof Component component ) {
final int[] originalPropertyOrder = component.sortProperties();
if ( !sorted ) {
@@ -197,28 +196,29 @@ public int[] sortProperties() {
public void createForeignKey(PersistentClass referencedEntity, AnnotatedJoinColumns joinColumns) {
// Ensure properties are sorted before we create a foreign key
sortProperties();
- if ( isForeignKeyEnabled() && referencedPropertyName==null && !hasFormula() ) {
- if ( isConstrained() ) {
- final AnnotatedJoinColumn firstColumn = joinColumns.getJoinColumns().get(0);
- final Object owner = findReferencedColumnOwner( referencedEntity, firstColumn, getBuildingContext() );
- if ( owner instanceof Join join ) {
- // Here we handle the case of a foreign key that refers to the
- // primary key of a secondary table of the referenced entity
- final ForeignKey foreignKey = getTable().createForeignKey(
- getForeignKeyName(),
- getConstraintColumns(),
- referencedEntity.getEntityName(),
- getForeignKeyDefinition(),
- getForeignKeyOptions(),
- join.getKey().getColumns()
- );
- foreignKey.setOnDeleteAction( getOnDeleteAction() );
- foreignKey.setReferencedTable( join.getTable() );
- }
- else {
- // it's just a reference to the primary key of the main table
- createForeignKeyOfEntity( referencedEntity.getEntityName() );
- }
+ if ( isForeignKeyEnabled()
+ && referencedPropertyName == null
+ && !hasFormula()
+ && isConstrained() ) {
+ final var firstColumn = joinColumns.getJoinColumns().get( 0 );
+ final Object owner = findReferencedColumnOwner( referencedEntity, firstColumn, getBuildingContext() );
+ if ( owner instanceof Join join ) {
+ // Here we handle the case of a foreign key that refers to the
+ // primary key of a secondary table of the referenced entity
+ final var foreignKey = getTable().createForeignKey(
+ getForeignKeyName(),
+ getConstraintColumns(),
+ referencedEntity.getEntityName(),
+ getForeignKeyDefinition(),
+ getForeignKeyOptions(),
+ join.getKey().getColumns()
+ );
+ foreignKey.setOnDeleteAction( getOnDeleteAction() );
+ foreignKey.setReferencedTable( join.getTable() );
+ }
+ else {
+ // it's just a reference to the primary key of the main table
+ createForeignKeyOfEntity( referencedEntity.getEntityName() );
}
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java b/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java
index 2a3d62a3364c..52ab7cc64da4 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java
@@ -63,8 +63,8 @@ public void setExplicit(boolean explicit) {
}
public boolean hasNullableColumn() {
- for ( Column column : getColumns() ) {
- final Column tableColumn = getTable().getColumn( column );
+ for ( var column : getColumns() ) {
+ final var tableColumn = getTable().getColumn( column );
if ( tableColumn != null && tableColumn.isNullable() ) {
return true;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/UserDefinedObjectType.java b/hibernate-core/src/main/java/org/hibernate/mapping/UserDefinedObjectType.java
index 4fd399f23c8c..dde4df0de0d1 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/UserDefinedObjectType.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/UserDefinedObjectType.java
@@ -5,7 +5,6 @@
package org.hibernate.mapping;
import java.util.Collection;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -42,7 +41,7 @@ public Column getColumn(Column column) {
return null;
}
else {
- final Column existing = columns.get( column.getCanonicalName() );
+ final var existing = columns.get( column.getCanonicalName() );
return column.equals( existing ) ? existing : null;
}
}
@@ -55,7 +54,7 @@ public Column getColumn(Identifier name) {
}
public Column getColumn(int n) {
- final Iterator iter = columns.values().iterator();
+ final var iter = columns.values().iterator();
for ( int i = 0; i < n - 1; i++ ) {
iter.next();
}
@@ -100,11 +99,11 @@ public void reorderColumns(List columns) {
}
orderMapping = new int[columns.size()];
int i = 0;
- for ( Column column : this.columns.values() ) {
+ for ( var column : this.columns.values() ) {
orderMapping[columns.indexOf( column )] = i++;
}
this.columns.clear();
- for ( Column column : columns ) {
+ for ( var column : columns ) {
this.columns.put( column.getCanonicalName(), column );
}
}