|
|
|
@ -80,7 +80,7 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements |
|
|
|
* {@link #MappingJdbcConverter(RelationalMappingContext, RelationResolver, CustomConversions, JdbcTypeFactory)} |
|
|
|
* {@link #MappingJdbcConverter(RelationalMappingContext, RelationResolver, CustomConversions, JdbcTypeFactory)} |
|
|
|
* (MappingContext, RelationResolver, JdbcTypeFactory)} to convert arrays and large objects into JDBC-specific types. |
|
|
|
* (MappingContext, RelationResolver, JdbcTypeFactory)} to convert arrays and large objects into JDBC-specific types. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param context must not be {@literal null}. |
|
|
|
* @param context must not be {@literal null}. |
|
|
|
* @param relationResolver used to fetch additional relations from the database. Must not be {@literal null}. |
|
|
|
* @param relationResolver used to fetch additional relations from the database. Must not be {@literal null}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public MappingJdbcConverter(RelationalMappingContext context, RelationResolver relationResolver) { |
|
|
|
public MappingJdbcConverter(RelationalMappingContext context, RelationResolver relationResolver) { |
|
|
|
@ -98,12 +98,12 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Creates a new {@link MappingJdbcConverter} given {@link MappingContext}. |
|
|
|
* Creates a new {@link MappingJdbcConverter} given {@link MappingContext}. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param context must not be {@literal null}. |
|
|
|
* @param context must not be {@literal null}. |
|
|
|
* @param relationResolver used to fetch additional relations from the database. Must not be {@literal null}. |
|
|
|
* @param relationResolver used to fetch additional relations from the database. Must not be {@literal null}. |
|
|
|
* @param typeFactory must not be {@literal null} |
|
|
|
* @param typeFactory must not be {@literal null} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public MappingJdbcConverter(RelationalMappingContext context, RelationResolver relationResolver, |
|
|
|
public MappingJdbcConverter(RelationalMappingContext context, RelationResolver relationResolver, |
|
|
|
CustomConversions conversions, JdbcTypeFactory typeFactory) { |
|
|
|
CustomConversions conversions, JdbcTypeFactory typeFactory) { |
|
|
|
|
|
|
|
|
|
|
|
super(context, conversions); |
|
|
|
super(context, conversions); |
|
|
|
|
|
|
|
|
|
|
|
@ -258,18 +258,18 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements |
|
|
|
|
|
|
|
|
|
|
|
if (convertedValue.getClass().isArray()) { |
|
|
|
if (convertedValue.getClass().isArray()) { |
|
|
|
|
|
|
|
|
|
|
|
if (componentType != byte.class && componentType != Byte.class) { |
|
|
|
if (componentType != byte.class && componentType != Byte.class) { |
|
|
|
|
|
|
|
|
|
|
|
Object[] objectArray = requireObjectArray(convertedValue); |
|
|
|
Object[] objectArray = requireObjectArray(convertedValue); |
|
|
|
return JdbcValue.of(typeFactory.createArray(objectArray), JDBCType.ARRAY); |
|
|
|
return JdbcValue.of(typeFactory.createArray(objectArray), JDBCType.ARRAY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (componentType == Byte.class) { |
|
|
|
if (componentType == Byte.class) { |
|
|
|
convertedValue = ArrayUtils.toPrimitive((Byte[]) convertedValue); |
|
|
|
convertedValue = ArrayUtils.toPrimitive((Byte[]) convertedValue); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return JdbcValue.of(convertedValue, JDBCType.BINARY); |
|
|
|
return JdbcValue.of(convertedValue, JDBCType.BINARY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return JdbcValue.of(convertedValue, sqlType); |
|
|
|
return JdbcValue.of(convertedValue, sqlType); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -306,7 +306,7 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected RelationalPropertyValueProvider newValueProvider(RowDocumentAccessor documentAccessor, |
|
|
|
protected RelationalPropertyValueProvider newValueProvider(RowDocumentAccessor documentAccessor, |
|
|
|
ValueExpressionEvaluator evaluator, ConversionContext context) { |
|
|
|
ValueExpressionEvaluator evaluator, ConversionContext context) { |
|
|
|
|
|
|
|
|
|
|
|
if (context instanceof ResolvingConversionContext rcc) { |
|
|
|
if (context instanceof ResolvingConversionContext rcc) { |
|
|
|
|
|
|
|
|
|
|
|
@ -335,7 +335,7 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements |
|
|
|
private final Identifier identifier; |
|
|
|
private final Identifier identifier; |
|
|
|
|
|
|
|
|
|
|
|
private ResolvingRelationalPropertyValueProvider(AggregatePathValueProvider delegate, RowDocumentAccessor accessor, |
|
|
|
private ResolvingRelationalPropertyValueProvider(AggregatePathValueProvider delegate, RowDocumentAccessor accessor, |
|
|
|
ResolvingConversionContext context, Identifier identifier) { |
|
|
|
ResolvingConversionContext context, Identifier identifier) { |
|
|
|
|
|
|
|
|
|
|
|
AggregatePath path = context.aggregatePath(); |
|
|
|
AggregatePath path = context.aggregatePath(); |
|
|
|
|
|
|
|
|
|
|
|
@ -344,7 +344,7 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements |
|
|
|
this.context = context; |
|
|
|
this.context = context; |
|
|
|
this.identifier = path.isEntity() |
|
|
|
this.identifier = path.isEntity() |
|
|
|
? potentiallyAppendIdentifier(identifier, path.getRequiredLeafEntity(), |
|
|
|
? potentiallyAppendIdentifier(identifier, path.getRequiredLeafEntity(), |
|
|
|
property -> delegate.getValue(path.append(property))) |
|
|
|
property -> delegate.getValue(path.append(property))) |
|
|
|
: identifier; |
|
|
|
: identifier; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -352,7 +352,7 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements |
|
|
|
* Conditionally append the identifier if the entity has an identifier property. |
|
|
|
* Conditionally append the identifier if the entity has an identifier property. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static Identifier potentiallyAppendIdentifier(Identifier base, RelationalPersistentEntity<?> entity, |
|
|
|
static Identifier potentiallyAppendIdentifier(Identifier base, RelationalPersistentEntity<?> entity, |
|
|
|
Function<RelationalPersistentProperty, Object> getter) { |
|
|
|
Function<RelationalPersistentProperty, Object> getter) { |
|
|
|
|
|
|
|
|
|
|
|
if (entity.hasIdProperty()) { |
|
|
|
if (entity.hasIdProperty()) { |
|
|
|
|
|
|
|
|
|
|
|
@ -481,7 +481,7 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements |
|
|
|
|
|
|
|
|
|
|
|
return context == this.context ? this |
|
|
|
return context == this.context ? this |
|
|
|
: new ResolvingRelationalPropertyValueProvider(delegate.withContext(context), accessor, |
|
|
|
: new ResolvingRelationalPropertyValueProvider(delegate.withContext(context), accessor, |
|
|
|
(ResolvingConversionContext) context, identifier); |
|
|
|
(ResolvingConversionContext) context, identifier); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -493,7 +493,7 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements |
|
|
|
* @param identifier |
|
|
|
* @param identifier |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private record ResolvingConversionContext(ConversionContext delegate, AggregatePath aggregatePath, |
|
|
|
private record ResolvingConversionContext(ConversionContext delegate, AggregatePath aggregatePath, |
|
|
|
Identifier identifier) implements ConversionContext { |
|
|
|
Identifier identifier) implements ConversionContext { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public <S> S convert(Object source, TypeInformation<? extends S> typeHint) { |
|
|
|
public <S> S convert(Object source, TypeInformation<? extends S> typeHint) { |
|
|
|
|