mark some incubations

This commit is contained in:
Steve Ebersole 2022-03-29 22:03:20 -05:00
parent e433f32fc6
commit 6d55b9b2a4
4 changed files with 55 additions and 16 deletions

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.boot.spi;
import org.hibernate.Incubating;
import org.hibernate.boot.model.TypeDefinitionRegistry;
import org.hibernate.boot.model.naming.ObjectNameNormalizer;
import org.hibernate.internal.util.config.ConfigurationHelper;
@ -51,18 +52,22 @@ public interface MetadataBuildingContext {
*/
ObjectNameNormalizer getObjectNameNormalizer();
@Incubating
default int getPreferredSqlTypeCodeForBoolean() {
return ConfigurationHelper.getPreferredSqlTypeCodeForBoolean( getBootstrapContext().getServiceRegistry() );
}
@Incubating
default int getPreferredSqlTypeCodeForDuration() {
return ConfigurationHelper.getPreferredSqlTypeCodeForDuration( getBootstrapContext().getServiceRegistry() );
}
@Incubating
default int getPreferredSqlTypeCodeForUuid() {
return ConfigurationHelper.getPreferredSqlTypeCodeForUuid( getBootstrapContext().getServiceRegistry() );
}
@Incubating
default int getPreferredSqlTypeCodeForInstant() {
return ConfigurationHelper.getPreferredSqlTypeCodeForInstant( getBootstrapContext().getServiceRegistry() );
}

View File

@ -11,6 +11,7 @@ import java.util.function.Supplier;
import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.EntityNameResolver;
import org.hibernate.Incubating;
import org.hibernate.Interceptor;
import org.hibernate.SessionFactoryObserver;
import org.hibernate.TimeZoneStorageStrategy;
@ -298,12 +299,16 @@ public interface SessionFactoryOptions extends QueryEngineOptions {
return false;
}
@Incubating
int getPreferredSqlTypeCodeForBoolean();
@Incubating
int getPreferredSqlTypeCodeForDuration();
@Incubating
int getPreferredSqlTypeCodeForUuid();
@Incubating
int getPreferredSqlTypeCodeForInstant();
TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy();

View File

@ -2503,11 +2503,12 @@ public interface AvailableSettings {
* Can be overridden locally using {@link org.hibernate.annotations.JdbcType},
* {@link org.hibernate.annotations.JdbcTypeCode} and friends
*
* Can also specify the name of the constant in {@link org.hibernate.type.SqlTypes} instead. E.g.
* Can also specify the name of the {@link org.hibernate.type.SqlTypes} constant field. E.g.
* {@code hibernate.type.preferred_boolean_jdbc_type=BIT}
*
* @since 6.0
*/
@Incubating
String PREFERRED_BOOLEAN_JDBC_TYPE = "hibernate.type.preferred_boolean_jdbc_type";
/**
@ -2516,23 +2517,27 @@ public interface AvailableSettings {
* Can be overridden locally using {@link org.hibernate.annotations.JdbcType},
* {@link org.hibernate.annotations.JdbcTypeCode} and friends
*
* Can also specify the name of the constant in {@link org.hibernate.type.SqlTypes} instead. E.g.
* Can also specify the name of the {@link org.hibernate.type.SqlTypes} constant field. E.g.
* {@code hibernate.type.preferred_uuid_jdbc_type=CHAR}
*
* @since 6.0
*/
@Incubating
String PREFERRED_UUID_JDBC_TYPE = "hibernate.type.preferred_uuid_jdbc_type";
/**
* Specifies the preferred JDBC type for storing duration values. When no
* type is explicitly specified, {@link org.hibernate.type.SqlTypes#INTERVAL_SECOND} is used.
* The preferred JDBC type to use for storing duration values. Falls back to
* {@link org.hibernate.type.SqlTypes#INTERVAL_SECOND}.
*
* Can be overridden locally using {@link org.hibernate.annotations.JdbcType},
* {@link org.hibernate.annotations.JdbcTypeCode} and friends
*
* Can also specify the name of the constant in {@link org.hibernate.type.SqlTypes} instead. E.g.
*Can also specify the name of the {@link org.hibernate.type.SqlTypes} constant field. E.g.
* {@code hibernate.type.preferred_duration_jdbc_type=NUMERIC}
*
* @since 6.0
*/
@Incubating
String PREFERRED_DURATION_JDBC_TYPE = "hibernate.type.preferred_duration_jdbc_type";
/**
@ -2542,15 +2547,16 @@ public interface AvailableSettings {
* Can be overridden locally using {@link org.hibernate.annotations.JdbcType},
* {@link org.hibernate.annotations.JdbcTypeCode} and friends
*
* Can also specify the name of the constant in {@link org.hibernate.type.SqlTypes} instead. E.g.
* Can also specify the name of the {@link org.hibernate.type.SqlTypes} constant field. E.g.
* {@code hibernate.type.preferred_instant_jdbc_type=TIMESTAMP}
*
* @since 6.0
*/
@Incubating
String PREFERRED_INSTANT_JDBC_TYPE = "hibernate.type.preferred_instant_jdbc_type";
/**
* Specifies a {@link org.hibernate.type.FormatMapper} used for for JSON serialization
* Specifies a {@link org.hibernate.type.FormatMapper} used for JSON serialization
* and deserialization, either:
* <ul>
* <li>an instance of {@code FormatMapper},

View File

@ -13,6 +13,7 @@ import java.util.Properties;
import java.util.StringTokenizer;
import java.util.function.Supplier;
import org.hibernate.Incubating;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.config.spi.ConfigurationService;
@ -22,6 +23,8 @@ import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.JdbcTypeNameMapper;
import static org.hibernate.internal.log.IncubationLogger.INCUBATION_LOGGER;
/**
* Collection of helper methods for dealing with configuration settings.
*
@ -513,12 +516,14 @@ public final class ConfigurationHelper {
}
}
@Incubating
public static synchronized int getPreferredSqlTypeCodeForBoolean(StandardServiceRegistry serviceRegistry) {
final Integer typeCode = serviceRegistry.getService( ConfigurationService.class ).getSetting(
AvailableSettings.PREFERRED_BOOLEAN_JDBC_TYPE,
TypeCodeConverter.INSTANCE
);
if ( typeCode != null ) {
INCUBATION_LOGGER.incubatingSetting( AvailableSettings.PREFERRED_BOOLEAN_JDBC_TYPE );
return typeCode;
}
@ -529,28 +534,46 @@ public final class ConfigurationHelper {
.getPreferredSqlTypeCodeForBoolean();
}
@Incubating
public static synchronized int getPreferredSqlTypeCodeForDuration(StandardServiceRegistry serviceRegistry) {
return serviceRegistry.getService( ConfigurationService.class ).getSetting(
final Integer explicitSetting = serviceRegistry.getService( ConfigurationService.class ).getSetting(
AvailableSettings.PREFERRED_DURATION_JDBC_TYPE,
TypeCodeConverter.INSTANCE,
SqlTypes.INTERVAL_SECOND
TypeCodeConverter.INSTANCE
);
if ( explicitSetting != null ) {
INCUBATION_LOGGER.incubatingSetting( AvailableSettings.PREFERRED_DURATION_JDBC_TYPE );
return explicitSetting;
}
return SqlTypes.INTERVAL_SECOND;
}
@Incubating
public static synchronized int getPreferredSqlTypeCodeForUuid(StandardServiceRegistry serviceRegistry) {
return serviceRegistry.getService( ConfigurationService.class ).getSetting(
final Integer explicitSetting = serviceRegistry.getService( ConfigurationService.class ).getSetting(
AvailableSettings.PREFERRED_UUID_JDBC_TYPE,
TypeCodeConverter.INSTANCE,
SqlTypes.UUID
TypeCodeConverter.INSTANCE
);
if ( explicitSetting != null ) {
INCUBATION_LOGGER.incubatingSetting( AvailableSettings.PREFERRED_UUID_JDBC_TYPE );
return explicitSetting;
}
return SqlTypes.UUID;
}
@Incubating
public static synchronized int getPreferredSqlTypeCodeForInstant(StandardServiceRegistry serviceRegistry) {
return serviceRegistry.getService( ConfigurationService.class ).getSetting(
final Integer explicitSetting = serviceRegistry.getService( ConfigurationService.class ).getSetting(
AvailableSettings.PREFERRED_INSTANT_JDBC_TYPE,
TypeCodeConverter.INSTANCE,
SqlTypes.TIMESTAMP_UTC
TypeCodeConverter.INSTANCE
);
if ( explicitSetting != null ) {
INCUBATION_LOGGER.incubatingSetting( AvailableSettings.PREFERRED_INSTANT_JDBC_TYPE );
return explicitSetting;
}
return SqlTypes.TIMESTAMP_UTC;
}
private static class TypeCodeConverter implements ConfigurationService.Converter<Integer> {