From 3088a2cfd0ce80a35af076402fbc7aebe8798a0e Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 10 Jul 2019 18:45:52 +0100 Subject: [PATCH] HHH-13494 Deprecate singleton access in favour of static helpers --- .../org/hibernate/mapping/SimpleValue.java | 4 +- .../type/descriptor/sql/LobTypeMappings.java | 40 +++++++++++++++---- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java index a563522f18..6b001b554c 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java @@ -597,8 +597,8 @@ public class SimpleValue implements KeyValue { ); int jdbcTypeCode = recommendedSqlType.getSqlType(); if ( isLob() ) { - if ( LobTypeMappings.INSTANCE.hasCorrespondingLobCode( jdbcTypeCode ) ) { - jdbcTypeCode = LobTypeMappings.INSTANCE.getCorrespondingLobCode( jdbcTypeCode ); + if ( LobTypeMappings.isMappedToKnownLobCode( jdbcTypeCode ) ) { + jdbcTypeCode = LobTypeMappings.getLobCodeTypeMapping( jdbcTypeCode ); } else { if ( Serializable.class.isAssignableFrom( entityAttributeJavaTypeDescriptor.getJavaType() ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/LobTypeMappings.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/LobTypeMappings.java index 8269f5aeb6..d68a7099bd 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/LobTypeMappings.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/LobTypeMappings.java @@ -16,17 +16,41 @@ import org.hibernate.type.descriptor.JdbcTypeNameMapper; * @author Steve Ebersole * @author Sanne Grinovero */ -public class LobTypeMappings { +public final class LobTypeMappings { /** * Singleton access + * @deprecated use the static method helpers instead. */ + @Deprecated public static final LobTypeMappings INSTANCE = new LobTypeMappings(); private LobTypeMappings() { } + /** + * + * @param jdbcTypeCode + * @return + * @deprecated use {@link #isMappedToKnownLobCode(int)} + */ + @Deprecated public boolean hasCorrespondingLobCode(final int jdbcTypeCode) { + return isMappedToKnownLobCode( jdbcTypeCode ); + } + + /** + * + * @param jdbcTypeCode + * @return + * @deprecated use {@link #getLobCodeTypeMapping(int)} + */ + @Deprecated + public int getCorrespondingLobCode(final int jdbcTypeCode) { + return getLobCodeTypeMapping( jdbcTypeCode ); + } + + public static boolean isMappedToKnownLobCode(final int jdbcTypeCode) { return // BLOB mappings jdbcTypeCode == Types.BLOB || @@ -47,7 +71,7 @@ public class LobTypeMappings { jdbcTypeCode == Types.LONGNVARCHAR; } - public int getCorrespondingLobCode(final int jdbcTypeCode) { + public static int getLobCodeTypeMapping(final int jdbcTypeCode) { switch ( jdbcTypeCode ) { // BLOB mappings @@ -71,12 +95,12 @@ public class LobTypeMappings { // Anything else: default: throw new IllegalArgumentException( - String.format( - Locale.ROOT, - "JDBC type-code [%s (%s)] not known to have a corresponding LOB equivalent", - jdbcTypeCode, - JdbcTypeNameMapper.getTypeName( jdbcTypeCode ) - ) ); + String.format( + Locale.ROOT, + "JDBC type-code [%s (%s)] not known to have a corresponding LOB equivalent", + jdbcTypeCode, + JdbcTypeNameMapper.getTypeName( jdbcTypeCode ) + ) ); } }