Skip to content

Commit

Permalink
HHH-13494 Deprecate singleton access in favour of static helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne authored and gbadner committed Aug 7, 2019
1 parent cd3b769 commit 3088a2c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
Expand Up @@ -597,8 +597,8 @@ public org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry getJava
);
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() ) ) {
Expand Down
Expand Up @@ -16,17 +16,41 @@
* @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 ||
Expand All @@ -47,7 +71,7 @@ public boolean hasCorrespondingLobCode(final int jdbcTypeCode) {
jdbcTypeCode == Types.LONGNVARCHAR;
}

public int getCorrespondingLobCode(final int jdbcTypeCode) {
public static int getLobCodeTypeMapping(final int jdbcTypeCode) {
switch ( jdbcTypeCode ) {

// BLOB mappings
Expand All @@ -71,12 +95,12 @@ public int getCorrespondingLobCode(final int jdbcTypeCode) {
// 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 )
) );
}
}

Expand Down

0 comments on commit 3088a2c

Please sign in to comment.