From b72d332b34cc98d0b60c7a7d70110aa9e7943917 Mon Sep 17 00:00:00 2001 From: Gavin Date: Thu, 5 Jan 2023 21:06:53 +0100 Subject: [PATCH] add temporary table-related settings to AvailableSettings --- .../model/IdentifierGeneratorDefinition.java | 4 +- .../org/hibernate/cfg/AvailableSettings.java | 44 +++++++++++++++++-- .../dialect/temptable/TemporaryTableKind.java | 4 +- .../query/sqm/mutation/spi/package-info.java | 11 +++++ 4 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/spi/package-info.java diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/IdentifierGeneratorDefinition.java b/hibernate-core/src/main/java/org/hibernate/boot/model/IdentifierGeneratorDefinition.java index 6948ec14e5..37ce062835 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/IdentifierGeneratorDefinition.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/IdentifierGeneratorDefinition.java @@ -16,7 +16,6 @@ import java.util.Objects; import org.hibernate.AssertionFailure; import org.hibernate.Internal; import org.hibernate.id.IdentifierGenerator; -import org.hibernate.internal.util.collections.CollectionHelper; import jakarta.persistence.GenerationType; import jakarta.persistence.Index; @@ -26,6 +25,7 @@ import jakarta.persistence.UniqueConstraint; import static java.util.Collections.emptyMap; import static java.util.Collections.unmodifiableMap; +import static org.hibernate.internal.util.collections.CollectionHelper.isEmpty; /** * Models the definition of an {@linkplain org.hibernate.id.IdentityGenerator identifier generator} @@ -47,7 +47,7 @@ public class IdentifierGeneratorDefinition implements Serializable { final Map parameters) { this.name = name; this.strategy = strategy; - this.parameters = CollectionHelper.isEmpty( parameters ) ? emptyMap() : unmodifiableMap( parameters ); + this.parameters = isEmpty( parameters ) ? emptyMap() : unmodifiableMap( parameters ); } public IdentifierGeneratorDefinition( 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 0de2008306..ff8298c1d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java @@ -23,6 +23,9 @@ import org.hibernate.jpa.LegacySpecHints; import org.hibernate.jpa.SpecHints; import org.hibernate.query.spi.QueryPlan; import org.hibernate.query.sqm.NullPrecedence; +import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableStrategy; +import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableStrategy; +import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableStrategy; import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode; import org.hibernate.resource.jdbc.spi.StatementInspector; @@ -894,6 +897,7 @@ public interface AvailableSettings { * * @deprecated {@code hbm.xml} mappings are no longer supported, making this attribute irrelevant */ + @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated(since = "6", forRemoval = true) String ARTIFACT_PROCESSING_ORDER = "hibernate.mapping.precedence"; @@ -1159,6 +1163,7 @@ public interface AvailableSettings { * @deprecated Will be removed without replacement. See HHH-15631 */ @Deprecated(forRemoval = true) + @SuppressWarnings("DeprecatedIsStillUsed") String USE_REFLECTION_OPTIMIZER = "hibernate.bytecode.use_reflection_optimizer"; /** @@ -1408,6 +1413,7 @@ public interface AvailableSettings { * @deprecated this is only honored for {@code hibernate-infinispan} */ @Deprecated + @SuppressWarnings("DeprecatedIsStillUsed") String CACHE_KEYS_FACTORY = "hibernate.cache.keys_factory"; /** @@ -1685,10 +1691,10 @@ public interface AvailableSettings { * For cases where the {@value #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. - * + *

* Values are: {@code true} for appending schema commands to the end of the file, {@code false} * for writing schema commands at the beginning. - * + *

* The default value is {@code true} */ String HBM2DDL_SCRIPTS_CREATE_APPEND = "hibernate.hbm2ddl.schema-generation.script.append"; @@ -2467,6 +2473,7 @@ public interface AvailableSettings { * no {@code @OrderColumn}. */ @Deprecated( since = "6.0" ) + @SuppressWarnings("DeprecatedIsStillUsed") String JPA_LIST_COMPLIANCE = "hibernate.jpa.compliance.list"; /** @@ -3091,6 +3098,7 @@ public interface AvailableSettings { * @deprecated Will be removed without replacement. See HHH-15641 */ @Deprecated(forRemoval = true) + @SuppressWarnings("DeprecatedIsStillUsed") String ENHANCER_ENABLE_DIRTY_TRACKING = "hibernate.enhancer.enableDirtyTracking"; /** @@ -3098,6 +3106,7 @@ public interface AvailableSettings { * * @deprecated Will be removed without replacement. See HHH-15641 */ + @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated(forRemoval = true) String ENHANCER_ENABLE_LAZY_INITIALIZATION = "hibernate.enhancer.enableLazyInitialization"; @@ -3148,7 +3157,7 @@ public interface AvailableSettings { String VALIDATE_XML = "hibernate.validate_xml"; /** - * Enables processing `hbm.xml` mappings by transforming them to `mapping.xml` and using + * Enables processing {@code hbm.xml} mappings by transforming them to {@code mapping.xml} and using * that processor. Default is false, must be opted-into. * * @since 6.1 @@ -3156,7 +3165,7 @@ public interface AvailableSettings { String TRANSFORM_HBM_XML = "hibernate.transform_hbm_xml.enabled"; /** - * How features in a `hbm.xml` file which are not supported for transformation should be handled. + * How features in a {@code hbm.xml} file which are not supported for transformation should be handled. *

* Default is {@link org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling#ERROR} * @@ -3164,4 +3173,31 @@ public interface AvailableSettings { * @since 6.1 */ String TRANSFORM_HBM_XML_FEATURE_HANDLING = "hibernate.transform_hbm_xml.unsupported_feature_handling"; + + /** + * Allows creation of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#PERSISTENT persistent} + * temporary tables at application startup to be disabled. By default, table creation is enabled. + */ + String BULK_ID_STRATEGY_PERSISTENT_TEMPORARY_CREATE_TABLES = PersistentTableStrategy.CREATE_ID_TABLES; + /** + * Allows dropping of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#PERSISTENT persistent} + * temporary tables at application shutdown to be disabled. By default, table dropping is enabled. + */ + String BULK_ID_STRATEGY_PERSISTENT_TEMPORARY_DROP_TABLES = PersistentTableStrategy.DROP_ID_TABLES; + /** + * Allows creation of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#GLOBAL global} + * temporary tables at application startup to be disabled. By default, table creation is enabled. + */ + String BULK_ID_STRATEGY_GLOBAL_TEMPORARY_CREATE_TABLES = GlobalTemporaryTableStrategy.CREATE_ID_TABLES; + /** + * Allows dropping of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#GLOBAL global} + * temporary tables at application shutdown to be disabled. By default, table dropping is enabled. + */ + String BULK_ID_STRATEGY_GLOBAL_TEMPORARY_DROP_TABLES = GlobalTemporaryTableStrategy.DROP_ID_TABLES; + /** + * Allows dropping of {@linkplain org.hibernate.dialect.temptable.TemporaryTableKind#LOCAL local} + * temporary tables at transaction commit to be enabled. By default, table dropping is disabled, + * and the database will drop the temporary tables automatically. + */ + String BULK_ID_STRATEGY_LOCAL_TEMPORARY_DROP_TABLES = LocalTemporaryTableStrategy.DROP_ID_TABLES; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/temptable/TemporaryTableKind.java b/hibernate-core/src/main/java/org/hibernate/dialect/temptable/TemporaryTableKind.java index ab421b6f1d..959ff402f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/temptable/TemporaryTableKind.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/temptable/TemporaryTableKind.java @@ -20,7 +20,7 @@ public enum TemporaryTableKind { *

* The table is created once on application startup, unless {@value org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableStrategy#CREATE_ID_TABLES} * is disabled and dropped on application startup unless {@value org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableStrategy#CREATE_ID_TABLES} - * and {@value org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableStrategy#DROP_ID_TABLES} are + * or {@value org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableStrategy#DROP_ID_TABLES} are * disabled. */ PERSISTENT, @@ -39,7 +39,7 @@ public enum TemporaryTableKind { *

* The table is created once on application startup, unless {@value org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableStrategy#CREATE_ID_TABLES} * is disabled and dropped on application startup unless {@value org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableStrategy#CREATE_ID_TABLES} - * and {@value org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableStrategy#DROP_ID_TABLES} are + * or {@value org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableStrategy#DROP_ID_TABLES} are * disabled. */ GLOBAL; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/spi/package-info.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/spi/package-info.java new file mode 100644 index 0000000000..95a83c126a --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/spi/package-info.java @@ -0,0 +1,11 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ + +/** + * SPI for handling SQM UPDATE and DELETE queries + */ +package org.hibernate.query.sqm.mutation.spi;