HHH-16388 Treat wrapper arrays with @Lob like the legacy mapping would
This commit is contained in:
parent
214b647f0f
commit
06bb9fb046
|
@ -20,6 +20,7 @@ import org.hibernate.mapping.Selectable;
|
|||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.tool.schema.extract.spi.ColumnTypeInformation;
|
||||
import org.hibernate.type.AdjustableBasicType;
|
||||
import org.hibernate.type.BasicPluralType;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.SerializableType;
|
||||
import org.hibernate.type.descriptor.converter.internal.NamedEnumValueConverter;
|
||||
|
@ -199,9 +200,10 @@ public class InferredBasicValueResolver {
|
|||
typeConfiguration,
|
||||
dialect,
|
||||
resolveSqlTypeIndicators( stdIndicators, registeredElementType, elementJtd ),
|
||||
columnTypeInformation
|
||||
columnTypeInformation,
|
||||
stdIndicators
|
||||
);
|
||||
if ( registeredType != null ) {
|
||||
if ( registeredType instanceof BasicPluralType<?, ?> ) {
|
||||
typeConfiguration.getBasicTypeRegistry().register( registeredType );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -437,7 +437,8 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
getTypeConfiguration(),
|
||||
getDialect(),
|
||||
registeredElementType,
|
||||
column instanceof ColumnTypeInformation ? (ColumnTypeInformation) column : null
|
||||
column instanceof ColumnTypeInformation ? (ColumnTypeInformation) column : null,
|
||||
this
|
||||
);
|
||||
if ( registeredType != null ) {
|
||||
getTypeConfiguration().getBasicTypeRegistry().register( registeredType );
|
||||
|
@ -861,6 +862,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
|||
@Internal
|
||||
public boolean isDisallowedWrapperArray() {
|
||||
return getBuildingContext().getBuildingOptions().getWrapperArrayHandling() == WrapperArrayHandling.DISALLOW
|
||||
&& !isLob()
|
||||
&& ( explicitJavaTypeAccess == null || explicitJavaTypeAccess.apply( getTypeConfiguration() ) == null )
|
||||
&& isWrapperByteOrCharacterArray();
|
||||
}
|
||||
|
|
|
@ -65,7 +65,8 @@ public abstract class AbstractArrayJavaType<T, E> extends AbstractClassJavaType<
|
|||
TypeConfiguration typeConfiguration,
|
||||
Dialect dialect,
|
||||
BasicType<E> elementType,
|
||||
ColumnTypeInformation columnTypeInformation) {
|
||||
ColumnTypeInformation columnTypeInformation,
|
||||
JdbcTypeIndicators stdIndicators) {
|
||||
final Class<?> elementJavaTypeClass = elementType.getJavaTypeDescriptor().getJavaTypeClass();
|
||||
if ( elementType instanceof BasicPluralType<?, ?> || elementJavaTypeClass != null && elementJavaTypeClass.isArray() ) {
|
||||
return null;
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.hibernate.type.descriptor.WrapperOptions;
|
|||
import org.hibernate.type.descriptor.converter.spi.BasicValueConverter;
|
||||
import org.hibernate.type.descriptor.jdbc.ArrayJdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
|
@ -55,7 +56,23 @@ public class ArrayJavaType<T> extends AbstractArrayJavaType<T[], T> {
|
|||
TypeConfiguration typeConfiguration,
|
||||
Dialect dialect,
|
||||
BasicType<T> elementType,
|
||||
ColumnTypeInformation columnTypeInformation) {
|
||||
ColumnTypeInformation columnTypeInformation,
|
||||
JdbcTypeIndicators stdIndicators) {
|
||||
if ( stdIndicators.isLob() ) {
|
||||
final Class<?> javaTypeClass = getJavaTypeClass();
|
||||
if ( javaTypeClass == Byte[].class ) {
|
||||
return typeConfiguration.getBasicTypeRegistry().resolve(
|
||||
ByteArrayJavaType.INSTANCE,
|
||||
ByteArrayJavaType.INSTANCE.getRecommendedJdbcType( stdIndicators )
|
||||
);
|
||||
}
|
||||
if ( javaTypeClass == Character[].class ) {
|
||||
return typeConfiguration.getBasicTypeRegistry().resolve(
|
||||
CharacterArrayJavaType.INSTANCE,
|
||||
CharacterArrayJavaType.INSTANCE.getRecommendedJdbcType( stdIndicators )
|
||||
);
|
||||
}
|
||||
}
|
||||
final Class<?> elementJavaTypeClass = elementType.getJavaTypeDescriptor().getJavaTypeClass();
|
||||
if ( elementType instanceof BasicPluralType<?, ?> || elementJavaTypeClass != null && elementJavaTypeClass.isArray() ) {
|
||||
return null;
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.hibernate.Incubating;
|
|||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.tool.schema.extract.spi.ColumnTypeInformation;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
|
@ -38,6 +39,7 @@ public interface BasicPluralJavaType<T> extends Serializable {
|
|||
TypeConfiguration typeConfiguration,
|
||||
Dialect dialect,
|
||||
BasicType<T> elementType,
|
||||
ColumnTypeInformation columnTypeInformation);
|
||||
ColumnTypeInformation columnTypeInformation,
|
||||
JdbcTypeIndicators stdIndicators);
|
||||
|
||||
}
|
||||
|
|
|
@ -94,7 +94,8 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
|
|||
TypeConfiguration typeConfiguration,
|
||||
Dialect dialect,
|
||||
BasicType<E> elementType,
|
||||
ColumnTypeInformation columnTypeInformation) {
|
||||
ColumnTypeInformation columnTypeInformation,
|
||||
JdbcTypeIndicators stdIndicators) {
|
||||
final Class<?> elementJavaTypeClass = elementType.getJavaTypeDescriptor().getJavaTypeClass();
|
||||
if ( elementType instanceof BasicPluralType<?, ?>
|
||||
|| elementJavaTypeClass != null && elementJavaTypeClass.isArray() ) {
|
||||
|
|
|
@ -145,7 +145,6 @@ public class ByteArrayMappingTests {
|
|||
@Lob
|
||||
private byte[] primitiveLob;
|
||||
@Lob
|
||||
@JavaType( ByteArrayJavaType.class )
|
||||
private Byte[] wrapperLob;
|
||||
//end::basic-bytearray-example[]
|
||||
|
||||
|
|
|
@ -119,7 +119,6 @@ public class CharacterArrayMappingTests {
|
|||
@Lob
|
||||
char[] primitiveClob;
|
||||
@Lob
|
||||
@JavaType( CharacterArrayJavaType.class )
|
||||
Character[] wrapperClob;
|
||||
//end::basic-chararray-example[]
|
||||
}
|
||||
|
|
|
@ -132,7 +132,6 @@ public class CharacterArrayNationalizedMappingTests {
|
|||
char[] primitiveNClob;
|
||||
@Lob
|
||||
@Nationalized
|
||||
@JavaType( CharacterArrayJavaType.class )
|
||||
Character[] wrapperNClob;
|
||||
//end::basic-nchararray-example[]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue