Skip to content

Commit ddb8921

Browse files
committed
Workaround JDK 17 javac bug for switch expression compilation
1 parent e2b93cb commit ddb8921

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

hibernate-core/src/main/java/org/hibernate/type/internal/BindingTypeHelper.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ public static JdbcMapping resolveBindType(
9797
final var javaType = value.getClass();
9898
final var temporalJavaType = (TemporalJavaType<?>) baseType.getJdbcJavaType();
9999
final var bindableType = (BindableType<?>) baseType;
100-
return (JdbcMapping) switch ( temporalJavaType.getPrecision() ) {
101-
case TIMESTAMP -> resolveTimestampTemporalTypeVariant( javaType, bindableType, typeConfiguration );
102-
case DATE -> resolveDateTemporalTypeVariant( javaType, bindableType, typeConfiguration );
103-
case TIME -> resolveTimeTemporalTypeVariant( javaType, bindableType, typeConfiguration );
100+
// Cast individual arms of the switch to avoid a JDK 17 javac bug
101+
return switch ( temporalJavaType.getPrecision() ) {
102+
case TIMESTAMP -> (JdbcMapping) resolveTimestampTemporalTypeVariant( javaType, bindableType, typeConfiguration );
103+
case DATE -> (JdbcMapping) resolveDateTemporalTypeVariant( javaType, bindableType, typeConfiguration );
104+
case TIME -> (JdbcMapping) resolveTimeTemporalTypeVariant( javaType, bindableType, typeConfiguration );
104105
};
105106
}
106107
}

0 commit comments

Comments
 (0)