minor code cleanups

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-04-27 14:36:19 +02:00
parent 88bdfbfbd4
commit c955150b27
3 changed files with 16 additions and 24 deletions

View File

@ -1002,7 +1002,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
private static TimeZoneStorageType resolveTimeZoneStorageStrategy( private static TimeZoneStorageType resolveTimeZoneStorageStrategy(
ConfigurationService configService) { ConfigurationService configService) {
return configService.getSetting( return configService.getSetting(
AvailableSettings.TIMEZONE_DEFAULT_STORAGE, AvailableSettings.TIMEZONE_DEFAULT_STORAGE,
value -> TimeZoneStorageType.valueOf( value.toString() ), value -> TimeZoneStorageType.valueOf( value.toString() ),
TimeZoneStorageType.DEFAULT TimeZoneStorageType.DEFAULT
@ -1017,7 +1017,7 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
WRAPPER_ARRAY_HANDLING, WRAPPER_ARRAY_HANDLING,
WrapperArrayHandling::interpretExternalSettingLeniently WrapperArrayHandling::interpretExternalSettingLeniently
), ),
() -> resolveFallbackWrapperArrayHandling( configService, serviceRegistry ) () -> resolveFallbackWrapperArrayHandling( configService )
); );
if ( setting == WrapperArrayHandling.PICK ) { if ( setting == WrapperArrayHandling.PICK ) {
@ -1035,9 +1035,8 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
}; };
private static WrapperArrayHandling resolveFallbackWrapperArrayHandling( private static WrapperArrayHandling resolveFallbackWrapperArrayHandling(
ConfigurationService configService, ConfigurationService configService) {
StandardServiceRegistry serviceRegistry) { if ( configService.getSetting( JPA_COMPLIANCE, BOOLEAN, false ) ) {
if ( configService.getSetting( JPA_COMPLIANCE, BOOLEAN ) == Boolean.TRUE ) {
// JPA compliance was enabled. Use PICK // JPA compliance was enabled. Use PICK
return WrapperArrayHandling.PICK; return WrapperArrayHandling.PICK;
} }

View File

@ -126,6 +126,7 @@ import org.hibernate.type.spi.TypeConfiguration;
import jakarta.persistence.TemporalType; import jakarta.persistence.TemporalType;
import static org.hibernate.dialect.HANAServerConfiguration.MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE;
import static org.hibernate.query.sqm.produce.function.FunctionParameterType.ANY; import static org.hibernate.query.sqm.produce.function.FunctionParameterType.ANY;
import static org.hibernate.type.SqlTypes.BINARY; import static org.hibernate.type.SqlTypes.BINARY;
import static org.hibernate.type.SqlTypes.BOOLEAN; import static org.hibernate.type.SqlTypes.BOOLEAN;
@ -1763,7 +1764,7 @@ public abstract class AbstractHANADialect extends Dialect {
if ( nclob == null ) { if ( nclob == null ) {
return null; return null;
} }
if ( nclob.length() < HANANClobJdbcType.this.maxLobPrefetchSize ) { if ( nclob.length() < maxLobPrefetchSize ) {
X retVal = javaType.wrap(nclob, options); X retVal = javaType.wrap(nclob, options);
nclob.free(); nclob.free();
return retVal; return retVal;
@ -1790,14 +1791,14 @@ public abstract class AbstractHANADialect extends Dialect {
} }
public int getMaxLobPrefetchSize() { public int getMaxLobPrefetchSize() {
return this.maxLobPrefetchSize; return maxLobPrefetchSize;
} }
} }
public static class HANABlobType implements JdbcType { public static class HANABlobType implements JdbcType {
private static final long serialVersionUID = 5874441715643764323L; private static final long serialVersionUID = 5874441715643764323L;
public static final JdbcType INSTANCE = new HANABlobType( HANAServerConfiguration.MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE ); public static final JdbcType INSTANCE = new HANABlobType( MAX_LOB_PREFETCH_SIZE_DEFAULT_VALUE );
final int maxLobPrefetchSize; final int maxLobPrefetchSize;
@ -1815,7 +1816,7 @@ public abstract class AbstractHANADialect extends Dialect {
@Override @Override
public String getFriendlyName() { public String getFriendlyName() {
return "BLOB (hana)"; return "BLOB (HANA)";
} }
@Override @Override
@ -1830,7 +1831,7 @@ public abstract class AbstractHANADialect extends Dialect {
if ( blob == null ) { if ( blob == null ) {
return null; return null;
} }
if (blob.length() < HANABlobType.this.maxLobPrefetchSize ) { if ( blob.length() < maxLobPrefetchSize ) {
X retVal = javaType.wrap(blob, options); X retVal = javaType.wrap(blob, options);
blob.free(); blob.free();
return retVal; return retVal;
@ -1868,7 +1869,7 @@ public abstract class AbstractHANADialect extends Dialect {
descriptor = BlobJdbcType.PRIMITIVE_ARRAY_BINDING; descriptor = BlobJdbcType.PRIMITIVE_ARRAY_BINDING;
} }
else if ( options.useStreamForLobBinding() ) { else if ( options.useStreamForLobBinding() ) {
descriptor = HANABlobType.this.hanaStreamBlobTypeDescriptor; descriptor = hanaStreamBlobTypeDescriptor;
} }
descriptor.getBinder( javaType ).bind( st, value, index, options ); descriptor.getBinder( javaType ).bind( st, value, index, options );
} }
@ -1881,7 +1882,7 @@ public abstract class AbstractHANADialect extends Dialect {
descriptor = BlobJdbcType.PRIMITIVE_ARRAY_BINDING; descriptor = BlobJdbcType.PRIMITIVE_ARRAY_BINDING;
} }
else if ( options.useStreamForLobBinding() ) { else if ( options.useStreamForLobBinding() ) {
descriptor = HANABlobType.this.hanaStreamBlobTypeDescriptor; descriptor = hanaStreamBlobTypeDescriptor;
} }
descriptor.getBinder( javaType ).bind( st, value, name, options ); descriptor.getBinder( javaType ).bind( st, value, name, options );
} }
@ -1889,7 +1890,7 @@ public abstract class AbstractHANADialect extends Dialect {
} }
public int getMaxLobPrefetchSize() { public int getMaxLobPrefetchSize() {
return this.maxLobPrefetchSize; return maxLobPrefetchSize;
} }
} }

View File

@ -895,17 +895,9 @@ public class OracleDialect extends Dialect {
// account for Oracle's deprecated support for LONGVARBINARY // account for Oracle's deprecated support for LONGVARBINARY
// prefer BLOB, unless the user explicitly opts out // prefer BLOB, unless the user explicitly opts out
boolean preferLong = serviceRegistry.requireService( ConfigurationService.class ).getSetting( final boolean preferLong = serviceRegistry.requireService( ConfigurationService.class )
PREFER_LONG_RAW, .getSetting( PREFER_LONG_RAW, StandardConverters.BOOLEAN, false );
StandardConverters.BOOLEAN, typeContributions.contributeJdbcType( preferLong ? BlobJdbcType.PRIMITIVE_ARRAY_BINDING : BlobJdbcType.DEFAULT );
false
);
BlobJdbcType descriptor = preferLong ?
BlobJdbcType.PRIMITIVE_ARRAY_BINDING :
BlobJdbcType.DEFAULT;
typeContributions.contributeJdbcType( descriptor );
if ( getVersion().isSameOrAfter( 21 ) ) { if ( getVersion().isSameOrAfter( 21 ) ) {
typeContributions.contributeJdbcType( OracleJsonJdbcType.INSTANCE ); typeContributions.contributeJdbcType( OracleJsonJdbcType.INSTANCE );