diff --git a/gradle/libraries.gradle b/gradle/libraries.gradle index b7a86a018a..1ed339b8dc 100644 --- a/gradle/libraries.gradle +++ b/gradle/libraries.gradle @@ -13,7 +13,10 @@ ext { junitVintageVersion = '5.8.2' junit5Version = '5.8.2' - h2Version = '1.4.197' + h2Version = '2.1.210' + h2GisVersion = '2.0.0' +// h2Version = '1.4.197' +// h2GisVersion = '1.5.0' bytemanVersion = '4.0.16' //Compatible with JDK16 jnpVersion = '5.0.6.CR1' @@ -151,8 +154,8 @@ ext { byteman_install: "org.jboss.byteman:byteman-install:${bytemanVersion}", byteman_bmunit: "org.jboss.byteman:byteman-bmunit:${bytemanVersion}", h2: "com.h2database:h2:${h2Version}", - h2gis: "org.orbisgis:h2gis:1.5.0", - hsqldb: "org.hsqldb:hsqldb:2.3.6", + h2gis: "org.orbisgis:h2gis:${h2GisVersion}", + hsqldb: "org.hsqldb:hsqldb:2.6.1", derby: "org.apache.derby:derby:10.14.2.0", postgresql: 'org.postgresql:postgresql:42.2.16', mysql: 'mysql:mysql-connector-java:8.0.27', diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index 5674ebef65..13b5dd14d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -178,11 +178,7 @@ public class H2Dialect extends Dialect { case NCHAR: return columnType( CHAR ); case NVARCHAR: - case LONG32NVARCHAR: - case LONG32VARCHAR: return columnType( VARCHAR ); - case LONG32VARBINARY: - return columnType( VARBINARY ); } return super.columnType( sqlTypeCode ); } @@ -235,7 +231,7 @@ public class H2Dialect extends Dialect { jdbcTypeRegistry.addDescriptorIfAbsent( UUIDJdbcType.INSTANCE ); } if ( getVersion().isSameOrAfter( 1, 4, 198 ) ) { - jdbcTypeRegistry.addDescriptorIfAbsent( DurationIntervalSecondJdbcType.INSTANCE ); + jdbcTypeRegistry.addDescriptorIfAbsent( H2DurationIntervalSecondJdbcType.INSTANCE ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DurationIntervalSecondJdbcType.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2DurationIntervalSecondJdbcType.java similarity index 75% rename from hibernate-core/src/main/java/org/hibernate/dialect/DurationIntervalSecondJdbcType.java rename to hibernate-core/src/main/java/org/hibernate/dialect/H2DurationIntervalSecondJdbcType.java index b7f514229b..f249a75719 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DurationIntervalSecondJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2DurationIntervalSecondJdbcType.java @@ -26,9 +26,9 @@ import org.hibernate.type.descriptor.jdbc.JdbcType; /** * @author Christian Beikov */ -public class DurationIntervalSecondJdbcType implements JdbcType { +public class H2DurationIntervalSecondJdbcType implements JdbcType { - public static final DurationIntervalSecondJdbcType INSTANCE = new DurationIntervalSecondJdbcType(); + public static final H2DurationIntervalSecondJdbcType INSTANCE = new H2DurationIntervalSecondJdbcType(); @Override public int getJdbcTypeCode() { @@ -74,17 +74,32 @@ public class DurationIntervalSecondJdbcType implements JdbcType { return new BasicExtractor<>( javaType, this ) { @Override protected X doExtract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException { + // Handle the fact that a duration could also come as number of nanoseconds + final Object nativeValue = rs.getObject( paramIndex ); + if ( nativeValue instanceof Number ) { + return javaType.wrap( nativeValue, options ); + } return javaType.wrap( rs.getObject( paramIndex, Duration.class ), options ); } @Override protected X doExtract(CallableStatement statement, int index, WrapperOptions options) throws SQLException { + // Handle the fact that a duration could also come as number of nanoseconds + final Object nativeValue = statement.getObject( index ); + if ( nativeValue instanceof Number ) { + return javaType.wrap( nativeValue, options ); + } return javaType.wrap( statement.getObject( index, Duration.class ), options ); } @Override protected X doExtract(CallableStatement statement, String name, WrapperOptions options) throws SQLException { + // Handle the fact that a duration could also come as number of nanoseconds + final Object nativeValue = statement.getObject( name ); + if ( nativeValue instanceof Number ) { + return javaType.wrap( nativeValue, options ); + } return javaType.wrap( statement.getObject( name, Duration.class ), options ); } };