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