HHH-17162 - Deprecate/rename former bulk id strategy settings

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2023-10-24 20:43:50 +02:00 committed by Steve Ebersole
parent 2c9ce29600
commit cc306acf10
8 changed files with 51 additions and 10 deletions

View File

@ -331,32 +331,47 @@ public interface SchemaToolingSettings {
/**
* 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.
*
* @deprecated Use {@link PersistentTableStrategy#CREATE_ID_TABLES}.
*/
@Deprecated(forRemoval = true)
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.
*
* @deprecated Use {@link PersistentTableStrategy#DROP_ID_TABLES}.
*/
@Deprecated(forRemoval = true)
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.
*
* @deprecated Use {@link GlobalTemporaryTableStrategy#CREATE_ID_TABLES}.
*/
@Deprecated(forRemoval = true)
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.
*
* @deprecated Use {@link GlobalTemporaryTableStrategy#DROP_ID_TABLES}.
*/
@Deprecated(forRemoval = true)
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.
*
* @deprecated Use {@link LocalTemporaryTableStrategy#DROP_ID_TABLES}.
*/
@Deprecated(forRemoval = true)
String BULK_ID_STRATEGY_LOCAL_TEMPORARY_DROP_TABLES = LocalTemporaryTableStrategy.DROP_ID_TABLES;

View File

@ -99,6 +99,9 @@ import org.hibernate.query.spi.QueryImplementor;
import org.hibernate.query.sql.spi.NativeQueryImplementor;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
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.query.sqm.spi.NamedSqmQueryMemento;
import org.hibernate.relational.SchemaManager;
import org.hibernate.relational.internal.SchemaManagerImpl;
@ -132,6 +135,7 @@ import static org.hibernate.cfg.AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_VALIDATION_FACTORY;
import static org.hibernate.cfg.AvailableSettings.JPA_VALIDATION_FACTORY;
import static org.hibernate.internal.FetchProfileHelper.getFetchProfiles;
import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER;
import static org.hibernate.internal.util.config.ConfigurationHelper.getBoolean;
import static org.hibernate.jpa.HibernateHints.HINT_TENANT_ID;
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
@ -228,6 +232,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
settings = getSettings( options, serviceRegistry );
maskOutSensitiveInformation( settings );
deprecationCheck( settings );
LOG.debugf( "Instantiating SessionFactory with settings: %s", settings);
logIfEmptyCompositesEnabled( settings );
@ -329,6 +334,27 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
LOG.debug( "Instantiated SessionFactory" );
}
private void deprecationCheck(Map<String, Object> settings) {
for ( String s:settings.keySet() ) {
switch (s) {
case "hibernate.hql.bulk_id_strategy.global_temporary.create_tables":
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.global_temporary.create_tables", GlobalTemporaryTableStrategy.CREATE_ID_TABLES );
case "hibernate.hql.bulk_id_strategy.global_temporary.drop_tables":
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.global_temporary.drop_tables", GlobalTemporaryTableStrategy.DROP_ID_TABLES );
case "hibernate.hql.bulk_id_strategy.persistent.create_tables":
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.persistent.create_tables", PersistentTableStrategy.CREATE_ID_TABLES );
case "hibernate.hql.bulk_id_strategy.persistent.drop_tables":
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.persistent.drop_tables", PersistentTableStrategy.DROP_ID_TABLES );
case "hibernate.hql.bulk_id_strategy.persistent.schema":
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.persistent.schema", PersistentTableStrategy.SCHEMA );
case "hibernate.hql.bulk_id_strategy.persistent.catalog":
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.persistent.catalog", PersistentTableStrategy.CATALOG );
case "hibernate.hql.bulk_id_strategy.local_temporary.drop_tables":
DEPRECATION_LOGGER.deprecatedSetting( "hibernate.hql.bulk_id_strategy.local_temporary.drop_tables", LocalTemporaryTableStrategy.DROP_ID_TABLES );
}
}
}
private void initializeMappingModel(
MappingMetamodelImpl mappingMetamodelImpl,
BootstrapContext bootstrapContext,

View File

@ -30,9 +30,9 @@ public class GlobalTemporaryTableStrategy {
public static final String SHORT_NAME = "global_temporary";
public static final String CREATE_ID_TABLES = "hibernate.hql.bulk_id_strategy.global_temporary.create_tables";
public static final String CREATE_ID_TABLES = "hibernate.query.mutation_strategy.global_temporary.create_tables";
public static final String DROP_ID_TABLES = "hibernate.hql.bulk_id_strategy.global_temporary.drop_tables";
public static final String DROP_ID_TABLES = "hibernate.query.mutation_strategy.global_temporary.drop_tables";
private final TemporaryTable temporaryTable;

View File

@ -22,7 +22,7 @@ import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
public class LocalTemporaryTableStrategy {
public static final String SHORT_NAME = "local_temporary";
public static final String DROP_ID_TABLES = "hibernate.hql.bulk_id_strategy.local_temporary.drop_tables";
public static final String DROP_ID_TABLES = "hibernate.query.mutation_strategy.local_temporary.drop_tables";
private final TemporaryTable temporaryTable;
private final SessionFactoryImplementor sessionFactory;

View File

@ -32,13 +32,13 @@ public abstract class PersistentTableStrategy {
public static final String SHORT_NAME = "persistent";
public static final String CREATE_ID_TABLES = "hibernate.hql.bulk_id_strategy.persistent.create_tables";
public static final String CREATE_ID_TABLES = "hibernate.query.mutation_strategy.persistent.create_tables";
public static final String DROP_ID_TABLES = "hibernate.hql.bulk_id_strategy.persistent.drop_tables";
public static final String DROP_ID_TABLES = "hibernate.query.mutation_strategy.persistent.drop_tables";
public static final String SCHEMA = "hibernate.hql.bulk_id_strategy.persistent.schema";
public static final String SCHEMA = "hibernate.query.mutation_strategy.persistent.schema";
public static final String CATALOG = "hibernate.hql.bulk_id_strategy.persistent.catalog";
public static final String CATALOG = "hibernate.query.mutation_strategy.persistent.catalog";
private final TemporaryTable temporaryTable;
private final SessionFactoryImplementor sessionFactory;

View File

@ -28,4 +28,4 @@ hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFa
jakarta.persistence.validation.mode=NONE
hibernate.service.allow_crawling=false
hibernate.session.events.log=true
hibernate.hql.bulk_id_strategy.global_temporary.drop_tables=true
hibernate.query.mutation_strategy.global_temporary.drop_tables=true

View File

@ -25,4 +25,4 @@ hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFa
jakarta.persistence.validation.mode=NONE
hibernate.service.allow_crawling=false
hibernate.session.events.log=true
hibernate.hql.bulk_id_strategy.global_temporary.drop_tables=true
hibernate.query.mutation_strategy.global_temporary.drop_tables=true

View File

@ -25,4 +25,4 @@ hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFa
jakarta.persistence.validation.mode=NONE
hibernate.service.allow_crawling=false
hibernate.session.events.log=true
hibernate.hql.bulk_id_strategy.global_temporary.drop_tables=true
hibernate.query.mutation_strategy.global_temporary.drop_tables=true