HHH-17559 - Prefer Java Time handling for all temporal values
This commit is contained in:
parent
add62a188b
commit
a996b6514e
|
@ -100,7 +100,7 @@ public interface MetadataBuildingContext {
|
|||
|
||||
static boolean isPreferJavaTimeJdbcTypesEnabled(ConfigurationService configurationService) {
|
||||
return ConfigurationHelper.getBoolean(
|
||||
MappingSettings.PREFER_JAVA_TYPE_JDBC_TYPES,
|
||||
MappingSettings.JAVA_TIME_USE_DIRECT_JDBC,
|
||||
configurationService.getSettings(),
|
||||
// todo : true would be better eventually so maybe just rip off that band aid
|
||||
false
|
||||
|
|
|
@ -236,11 +236,11 @@ public interface MappingSettings {
|
|||
* {@linkplain org.hibernate.type.descriptor.jdbc.InstantJdbcType}.
|
||||
*
|
||||
* @settingDefault false
|
||||
*
|
||||
*
|
||||
* @since 6.5
|
||||
*/
|
||||
@Incubating
|
||||
String PREFER_JAVA_TYPE_JDBC_TYPES = "hibernate.type.prefer_java_type_jdbc_types";
|
||||
String JAVA_TIME_USE_DIRECT_JDBC = "hibernate.type.java_time_use_direct_jdbc";
|
||||
|
||||
/**
|
||||
* Indicates whether to prefer using SQL enums and the respective special JDBC types for binding/extracting
|
||||
|
|
|
@ -70,7 +70,7 @@ public interface JdbcTypeIndicators {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see org.hibernate.cfg.MappingSettings#PREFER_JAVA_TYPE_JDBC_TYPES
|
||||
* @see org.hibernate.cfg.MappingSettings#JAVA_TIME_USE_DIRECT_JDBC
|
||||
*/
|
||||
default boolean isPreferJavaTimeJdbcTypesEnabled() {
|
||||
return getCurrentBaseSqlTypeIndicators().isPreferJavaTimeJdbcTypesEnabled();
|
||||
|
|
|
@ -12,7 +12,6 @@ import java.time.LocalDateTime;
|
|||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.cfg.MappingSettings;
|
||||
import org.hibernate.community.dialect.AltibaseDialect;
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
|
@ -22,12 +21,8 @@ import org.hibernate.dialect.HANADialect;
|
|||
import org.hibernate.dialect.OracleDialect;
|
||||
import org.hibernate.dialect.SybaseDialect;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.Value;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.hibernate.type.descriptor.java.LocalDateJavaType;
|
||||
import org.hibernate.type.descriptor.jdbc.JavaTimeJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.LocalDateJdbcType;
|
||||
|
@ -58,7 +53,7 @@ import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecisio
|
|||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
@ServiceRegistry(
|
||||
settings = @Setting(name = MappingSettings.PREFER_JAVA_TYPE_JDBC_TYPES, value = "true")
|
||||
settings = @Setting(name = MappingSettings.JAVA_TIME_USE_DIRECT_JDBC, value = "true")
|
||||
)
|
||||
@DomainModel( annotatedClasses = GlobalJavaTimeJdbcTypeTests.EntityWithJavaTimeValues.class )
|
||||
@SessionFactory
|
||||
|
|
|
@ -10,19 +10,11 @@ import java.time.Instant;
|
|||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.cfg.MappingSettings;
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.dialect.DerbyDialect;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.dialect.OracleDialect;
|
||||
import org.hibernate.dialect.SybaseDialect;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.hibernate.type.descriptor.jdbc.DateJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.TimeJdbcType;
|
||||
|
@ -32,10 +24,7 @@ import org.hibernate.testing.orm.junit.DomainModel;
|
|||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.hibernate.testing.orm.junit.Setting;
|
||||
import org.hibernate.testing.orm.junit.SkipForDialect;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
|
@ -43,7 +32,6 @@ import jakarta.persistence.Id;
|
|||
import jakarta.persistence.Table;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecision;
|
||||
|
||||
/**
|
||||
* Tests for "direct" JDBC handling of {@linkplain java.time Java Time} types.
|
||||
|
@ -52,7 +40,7 @@ import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecisio
|
|||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
@ServiceRegistry(
|
||||
settings = @Setting(name = MappingSettings.PREFER_JAVA_TYPE_JDBC_TYPES, value = "false")
|
||||
settings = @Setting(name = MappingSettings.JAVA_TIME_USE_DIRECT_JDBC, value = "false")
|
||||
)
|
||||
@DomainModel( annotatedClasses = JavaTimeJdbcTypeBaselineTests.EntityWithJavaTimeValues.class )
|
||||
@SessionFactory
|
||||
|
|
|
@ -25,14 +25,10 @@ import org.hibernate.mapping.BasicValue;
|
|||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.hibernate.type.descriptor.jdbc.DateJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.JavaTimeJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.LocalDateJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.LocalDateTimeJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.LocalTimeJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.TimeJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.TimestampJdbcType;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
|
@ -58,7 +54,7 @@ import static org.hibernate.type.descriptor.DateTimeUtils.roundToDefaultPrecisio
|
|||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
@ServiceRegistry(
|
||||
settings = @Setting(name = MappingSettings.PREFER_JAVA_TYPE_JDBC_TYPES, value = "false")
|
||||
settings = @Setting(name = MappingSettings.JAVA_TIME_USE_DIRECT_JDBC, value = "false")
|
||||
)
|
||||
@DomainModel( annotatedClasses = JavaTimeJdbcTypeTests.EntityWithJavaTimeValues.class )
|
||||
@SessionFactory
|
||||
|
|
|
@ -32,13 +32,19 @@ those intermediate forms.
|
|||
|
||||
For 6.5 this behavior is disabled by default. To opt-in,
|
||||
|
||||
[source]
|
||||
[source,properties]
|
||||
----
|
||||
hibernate.type.prefer_java_type_jdbc_types=true
|
||||
hibernate.type.java_time_use_direct_jdbc=true
|
||||
----
|
||||
|
||||
NOTE: The name of this setting has been changed from `hibernate.type.prefer_java_type_jdbc_types` as first introduced in 6.5 CR1 to avoid confusion with the numerous `hibernate.type.prefer_<xyz>` settings.
|
||||
|
||||
IMPORTANT: This feature is known to not work with the Sybase jConnect driver despite
|
||||
this feature being part of JDBC since 4.2 (Java 8). We have notified the Sybase development team, but this seems unlikely to change.
|
||||
|
||||
It is expected the default will flip for 7.0.
|
||||
|
||||
|
||||
[[query-cache-layout]]
|
||||
== Configurable Query Cache Layout
|
||||
|
||||
|
|
|
@ -32,12 +32,16 @@ For 6.5 this behavior is disabled by default. To opt-in,
|
|||
|
||||
[source,properties]
|
||||
----
|
||||
hibernate.type.prefer_java_type_jdbc_types=true
|
||||
hibernate.type.java_time_use_direct_jdbc=true
|
||||
----
|
||||
|
||||
See the link:{javadocs-url}/org/hibernate/cfg/MappingSettings.html#PREFER_JAVA_TYPE_JDBC_TYPES[setting Javadoc] for additional details.
|
||||
|
||||
|
||||
IMPORTANT: This feature is known to not work with the Sybase jConnect driver despite
|
||||
this feature being part of JDBC since 4.2 (Java 8). We have notified the Sybase development team, but this seems unlikely to change.
|
||||
|
||||
|
||||
[[query-cache-layout]]
|
||||
== Configurable Query Cache Layout
|
||||
|
||||
|
|
Loading…
Reference in New Issue