@@ -72,6 +72,6 @@ public class BasicJdbcConverter extends MappingJdbcConverter {
|
||||
*/
|
||||
public BasicJdbcConverter(RelationalMappingContext context, RelationResolver relationResolver,
|
||||
CustomConversions conversions, JdbcTypeFactory typeFactory, IdentifierProcessing identifierProcessing) {
|
||||
super(context, relationResolver, conversions, typeFactory, identifierProcessing);
|
||||
super(context, relationResolver, conversions, typeFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
|
||||
return getMapEntityRowMapper(path, identifier).mapRow(rs, rowNum);
|
||||
}
|
||||
|
||||
// Add row number as key for paths that do not defile an identifier and that are contained in a collection.
|
||||
// Add row number as key for paths that do not define an identifier and that are contained in a collection.
|
||||
Identifier identifierToUse = identifier;
|
||||
if (!path.hasIdProperty() && path.isQualified()) {
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ public interface JdbcConverter extends RelationalConverter {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated(since = "3.2", forRemoval = true)
|
||||
default <T> T mapRow(PersistentPropertyPathExtension path, ResultSet resultSet, Identifier identifier, Object key) {
|
||||
|
||||
try {
|
||||
return (T) readAndResolve(path.getRequiredLeafEntity().getType(),
|
||||
RowDocumentResultSetExtractor.toRowDocument(resultSet), identifier);
|
||||
|
||||
@@ -44,7 +44,6 @@ import org.springframework.data.relational.core.mapping.AggregatePath;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
import org.springframework.data.relational.domain.RowDocument;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
@@ -77,7 +76,7 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements
|
||||
/**
|
||||
* Creates a new {@link MappingJdbcConverter} given {@link MappingContext} and a {@link JdbcTypeFactory#unsupported()
|
||||
* no-op type factory} throwing {@link UnsupportedOperationException} on type creation. Use
|
||||
* {@link #MappingJdbcConverter(RelationalMappingContext, RelationResolver, CustomConversions, JdbcTypeFactory, IdentifierProcessing)}
|
||||
* {@link #MappingJdbcConverter(RelationalMappingContext, RelationResolver, CustomConversions, JdbcTypeFactory)}
|
||||
* (MappingContext, RelationResolver, JdbcTypeFactory)} to convert arrays and large objects into JDBC-specific types.
|
||||
*
|
||||
* @param context must not be {@literal null}.
|
||||
@@ -112,13 +111,6 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements
|
||||
this.relationResolver = relationResolver;
|
||||
}
|
||||
|
||||
MappingJdbcConverter(RelationalMappingContext context, RelationResolver relationResolver,
|
||||
CustomConversions conversions, JdbcTypeFactory typeFactory, IdentifierProcessing identifierProcessing) {
|
||||
super(context, conversions);
|
||||
this.relationResolver = relationResolver;
|
||||
this.typeFactory = typeFactory;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Class<?> getEntityColumnType(Class<?> type) {
|
||||
|
||||
@@ -217,8 +209,8 @@ public class MappingJdbcConverter extends MappingRelationalConverter implements
|
||||
return true;
|
||||
}
|
||||
|
||||
if (AggregateReference.class.isAssignableFrom(value.getClass())) {
|
||||
return canWriteAsJdbcValue(((AggregateReference) value).getId());
|
||||
if (value instanceof AggregateReference aggregateReference) {
|
||||
return canWriteAsJdbcValue(aggregateReference.getId());
|
||||
}
|
||||
|
||||
RelationalPersistentEntity<?> persistentEntity = getMappingContext().getPersistentEntity(value.getClass());
|
||||
|
||||
@@ -60,7 +60,7 @@ class DefaultDataAccessStrategyUnitTests {
|
||||
DelegatingDataAccessStrategy relationResolver = new DelegatingDataAccessStrategy();
|
||||
Dialect dialect = HsqlDbDialect.INSTANCE;
|
||||
converter = new MappingJdbcConverter(context, relationResolver, new JdbcCustomConversions(),
|
||||
new DefaultJdbcTypeFactory(jdbcOperations), dialect.getIdentifierProcessing());
|
||||
new DefaultJdbcTypeFactory(jdbcOperations));
|
||||
accessStrategy = new DataAccessStrategyFactory( //
|
||||
new SqlGeneratorSource(context, converter, dialect), //
|
||||
converter, //
|
||||
|
||||
@@ -54,7 +54,6 @@ import org.springframework.data.relational.core.mapping.NamingStrategy;
|
||||
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedCaseInsensitiveMap;
|
||||
@@ -1066,7 +1065,7 @@ public class EntityRowMapperUnitTests {
|
||||
.findAllByPath(identifierOfValue(ID_FOR_ENTITY_REFERENCING_LIST), any(PersistentPropertyPath.class));
|
||||
|
||||
MappingJdbcConverter converter = new MappingJdbcConverter(context, accessStrategy, new JdbcCustomConversions(),
|
||||
JdbcTypeFactory.unsupported(), IdentifierProcessing.ANSI);
|
||||
JdbcTypeFactory.unsupported());
|
||||
|
||||
return new EntityRowMapper<>( //
|
||||
(RelationalPersistentEntity<T>) context.getRequiredPersistentEntity(type), //
|
||||
|
||||
@@ -41,7 +41,6 @@ import org.springframework.data.jdbc.core.mapping.JdbcValue;
|
||||
import org.springframework.data.jdbc.support.JdbcUtil;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
|
||||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
|
||||
import org.springframework.data.relational.core.sql.IdentifierProcessing;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
|
||||
/**
|
||||
@@ -59,7 +58,7 @@ public class MappingJdbcConverterUnitTests {
|
||||
throw new UnsupportedOperationException();
|
||||
}, //
|
||||
new JdbcCustomConversions(), //
|
||||
typeFactory, IdentifierProcessing.ANSI //
|
||||
typeFactory //
|
||||
);
|
||||
|
||||
@Test // DATAJDBC-104, DATAJDBC-1384
|
||||
|
||||
@@ -300,8 +300,7 @@ class SqlParametersFactoryTest {
|
||||
private SqlParametersFactory createSqlParametersFactoryWithConverters(List<?> converters) {
|
||||
|
||||
MappingJdbcConverter converter = new MappingJdbcConverter(context, relationResolver,
|
||||
new JdbcCustomConversions(converters), new DefaultJdbcTypeFactory(mock(JdbcOperations.class)),
|
||||
dialect.getIdentifierProcessing());
|
||||
new JdbcCustomConversions(converters), new DefaultJdbcTypeFactory(mock(JdbcOperations.class)));
|
||||
return new SqlParametersFactory(context, converter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ public abstract class AbstractRelationalConverter implements RelationalConverter
|
||||
this(context, conversions, new DefaultConversionService(), new EntityInstantiators());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private AbstractRelationalConverter(RelationalMappingContext context, CustomConversions conversions,
|
||||
ConfigurableConversionService conversionService, EntityInstantiators entityInstantiators) {
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
return read(TypeInformation.of(type), source);
|
||||
}
|
||||
|
||||
protected <S extends Object> S read(TypeInformation<S> type, RowDocument source) {
|
||||
protected <S> S read(TypeInformation<S> type, RowDocument source) {
|
||||
return readAggregate(getConversionContext(ObjectPath.ROOT), source, type);
|
||||
}
|
||||
|
||||
@@ -306,9 +306,8 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
* @param typeHint the {@link TypeInformation} to be used to unmarshall this {@link RowDocument}.
|
||||
* @return the converted object, will never be {@literal null}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <S extends Object> S readAggregate(ConversionContext context, RowDocument document,
|
||||
TypeInformation<? extends S> typeHint) {
|
||||
protected <S> S readAggregate(ConversionContext context, RowDocument document,
|
||||
TypeInformation<? extends S> typeHint) {
|
||||
return readAggregate(context, new RowDocumentAccessor(document), typeHint);
|
||||
}
|
||||
|
||||
@@ -321,8 +320,8 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
* @return the converted object, will never be {@literal null}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <S extends Object> S readAggregate(ConversionContext context, RowDocumentAccessor documentAccessor,
|
||||
TypeInformation<? extends S> typeHint) {
|
||||
protected <S> S readAggregate(ConversionContext context, RowDocumentAccessor documentAccessor,
|
||||
TypeInformation<? extends S> typeHint) {
|
||||
|
||||
Class<? extends S> rawType = typeHint.getType();
|
||||
|
||||
@@ -426,13 +425,13 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
return getPotentiallyConvertedSimpleRead(items, targetType);
|
||||
}
|
||||
|
||||
private <T extends Object> T doConvert(Object value, Class<? extends T> target) {
|
||||
private <T> T doConvert(Object value, Class<? extends T> target) {
|
||||
return doConvert(value, target, null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private <T extends Object> T doConvert(Object value, Class<? extends T> target,
|
||||
@Nullable Class<? extends T> fallback) {
|
||||
private <T> T doConvert(Object value, Class<? extends T> target,
|
||||
@Nullable Class<? extends T> fallback) {
|
||||
|
||||
if (getConversionService().canConvert(value.getClass(), target) || fallback == null) {
|
||||
return getConversionService().convert(value, target);
|
||||
@@ -788,8 +787,8 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <S extends Object> S convert(Object source, TypeInformation<? extends S> typeHint,
|
||||
ConversionContext context) {
|
||||
public <S> S convert(Object source, TypeInformation<? extends S> typeHint,
|
||||
ConversionContext context) {
|
||||
|
||||
Assert.notNull(source, "Source must not be null");
|
||||
Assert.notNull(typeHint, "TypeInformation must not be null");
|
||||
@@ -855,7 +854,7 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface ValueConverter<T> {
|
||||
interface ValueConverter<T> {
|
||||
|
||||
Object convert(T source, TypeInformation<?> typeHint);
|
||||
|
||||
@@ -867,7 +866,7 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface ContainerValueConverter<T> {
|
||||
interface ContainerValueConverter<T> {
|
||||
|
||||
Object convert(ConversionContext context, T source, TypeInformation<?> typeHint);
|
||||
|
||||
@@ -928,7 +927,7 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
* @param typeHint must not be {@literal null}.
|
||||
* @return the converted object.
|
||||
*/
|
||||
default <S extends Object> S convert(Object source, TypeInformation<? extends S> typeHint) {
|
||||
default <S> S convert(Object source, TypeInformation<? extends S> typeHint) {
|
||||
return convert(source, typeHint, this);
|
||||
}
|
||||
|
||||
@@ -940,7 +939,7 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
* @param context must not be {@literal null}.
|
||||
* @return the converted object.
|
||||
*/
|
||||
<S extends Object> S convert(Object source, TypeInformation<? extends S> typeHint, ConversionContext context);
|
||||
<S> S convert(Object source, TypeInformation<? extends S> typeHint, ConversionContext context);
|
||||
|
||||
/**
|
||||
* Obtain a {@link ConversionContext} for the given property {@code name}.
|
||||
@@ -998,7 +997,6 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
* Determine whether there is a value for the given {@link RelationalPersistentProperty}.
|
||||
*
|
||||
* @param property the property to check for whether a value is present.
|
||||
* @return
|
||||
*/
|
||||
boolean hasValue(RelationalPersistentProperty property);
|
||||
|
||||
@@ -1006,7 +1004,6 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
* Contextualize this property value provider.
|
||||
*
|
||||
* @param context the context to use.
|
||||
* @return
|
||||
*/
|
||||
RelationalPropertyValueProvider withContext(ConversionContext context);
|
||||
|
||||
@@ -1021,7 +1018,6 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
* Determine whether there is a value for the given {@link AggregatePath}.
|
||||
*
|
||||
* @param path the path to check for whether a value is present.
|
||||
* @return
|
||||
*/
|
||||
boolean hasValue(AggregatePath path);
|
||||
|
||||
@@ -1029,7 +1025,6 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
* Determine whether there is a value for the given {@link SqlIdentifier}.
|
||||
*
|
||||
* @param identifier the path to check for whether a value is present.
|
||||
* @return
|
||||
*/
|
||||
boolean hasValue(SqlIdentifier identifier);
|
||||
|
||||
@@ -1037,16 +1032,12 @@ public class MappingRelationalConverter extends AbstractRelationalConverter impl
|
||||
* Return a value for the given {@link AggregatePath}.
|
||||
*
|
||||
* @param path will never be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
Object getValue(AggregatePath path);
|
||||
|
||||
/**
|
||||
* Contextualize this property value provider.
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
AggregatePathValueProvider withContext(ConversionContext context);
|
||||
|
||||
@@ -52,7 +52,6 @@ public interface RelationalConverter {
|
||||
/**
|
||||
* Return the underlying {@link EntityInstantiators}.
|
||||
*
|
||||
* @return
|
||||
* @since 2.3
|
||||
*/
|
||||
EntityInstantiators getEntityInstantiators();
|
||||
@@ -109,7 +108,6 @@ public interface RelationalConverter {
|
||||
*
|
||||
* @param descriptor the projection descriptor, must not be {@literal null}.
|
||||
* @param document must not be {@literal null}.
|
||||
* @param <R>
|
||||
* @return a new instance of the projection return type {@code R}.
|
||||
* @since 3.2
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user