HHH-16591 - See documentation 2.2.21 - "By default, Hibernate maps Duration to the NUMERIC SQL type."

This commit is contained in:
Cedomir Igaly 2023-05-13 17:56:36 +02:00 committed by Christian Beikov
parent 049f24d67a
commit 280ff719bb
2 changed files with 10 additions and 1 deletions

View File

@ -400,7 +400,7 @@ Can also specify the name of the constant in `org.hibernate.type.SqlTypes` inste
Global setting identifying the preferred JDBC type code for storing uuid values. Global setting identifying the preferred JDBC type code for storing uuid values.
Can also specify the name of the constant in `org.hibernate.type.SqlTypes` instead. Can also specify the name of the constant in `org.hibernate.type.SqlTypes` instead.
`*hibernate.type.preferred_duration_jdbc_type*` (e.g. `2` for `java.sql.Types.NUMERIC` or `3100` for `org.hibernate.types.SqlTypes.INTERVAL_SECOND` (default value)):: `*hibernate.type.preferred_duration_jdbc_type*` (e.g. `2` for `java.sql.Types.NUMERIC` (default value) or `3100` for `org.hibernate.types.SqlTypes.INTERVAL_SECOND`)::
Global setting identifying the preferred JDBC type code for storing duration values. Global setting identifying the preferred JDBC type code for storing duration values.
Can also specify the name of the constant in `org.hibernate.type.SqlTypes` instead. Can also specify the name of the constant in `org.hibernate.type.SqlTypes` instead.

View File

@ -12,6 +12,7 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping; import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
@ -25,8 +26,10 @@ import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.type.spi.TypeConfiguration;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
@ -38,6 +41,12 @@ import static org.hamcrest.Matchers.is;
*/ */
@DomainModel(annotatedClasses = DurationMappingTests.EntityWithDuration.class) @DomainModel(annotatedClasses = DurationMappingTests.EntityWithDuration.class)
@SessionFactory @SessionFactory
/* Documentation:
*
* 2.2.21. Duration
* By default, Hibernate maps Duration to the NUMERIC SQL type.
*/
@ServiceRegistry(settings = @Setting(name = AvailableSettings.PREFERRED_DURATION_JDBC_TYPE, value = "INTERVAL_SECOND"))
public class DurationMappingTests { public class DurationMappingTests {
@Test @Test