Removed deprecations.

Removed deprecated API and usasage of deprecated API.

Closes #1340
This commit is contained in:
Jens Schauder
2022-09-27 13:03:52 +02:00
parent 98ef3df478
commit f326897950
20 changed files with 72 additions and 94 deletions

View File

@@ -50,7 +50,6 @@ import org.springframework.data.relational.core.conversion.RelationalConverter;
import org.springframework.data.relational.core.dialect.ArrayColumns;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
import org.springframework.r2dbc.core.Parameter;
@@ -107,7 +106,7 @@ public class MappingR2dbcConverter extends BasicRelationalConverter implements R
@Override
public <R> R read(Class<R> type, Row row, @Nullable RowMetadata metadata) {
TypeInformation<? extends R> typeInfo = ClassTypeInformation.from(type);
TypeInformation<? extends R> typeInfo = TypeInformation.of(type);
Class<? extends R> rawType = typeInfo.getType();
if (Row.class.isAssignableFrom(rawType)) {
@@ -132,7 +131,7 @@ public class MappingR2dbcConverter extends BasicRelationalConverter implements R
for (RelationalPersistentProperty property : entity) {
if (entity.isConstructorArgument(property)) {
if (entity.isCreatorArgument(property)) {
continue;
}
@@ -185,12 +184,10 @@ public class MappingR2dbcConverter extends BasicRelationalConverter implements R
return readValue(value, property.getTypeInformation());
} catch (Exception o_O) {
throw new MappingException(String.format("Could not read property %s from column %s", property, identifier),
o_O);
throw new MappingException(String.format("Could not read property %s from column %s", property, identifier), o_O);
}
}
public Object readValue(@Nullable Object value, TypeInformation<?> type) {
if (null == value) {
@@ -224,7 +221,7 @@ public class MappingR2dbcConverter extends BasicRelationalConverter implements R
TypeInformation<?> componentType = targetType.getComponentType() != null //
? targetType.getComponentType() //
: ClassTypeInformation.OBJECT;
: TypeInformation.OBJECT;
Class<?> rawComponentType = componentType.getType();
Collection<Object> items = targetType.getType().isArray() //
@@ -302,7 +299,7 @@ public class MappingR2dbcConverter extends BasicRelationalConverter implements R
getConversionService());
for (RelationalPersistentProperty p : entity) {
if (!entity.isConstructorArgument(property)) {
if (!entity.isCreatorArgument(property)) {
propertyAccessor.setProperty(p, readFrom(row, metadata, p, prefix));
}
}
@@ -405,7 +402,7 @@ public class MappingR2dbcConverter extends BasicRelationalConverter implements R
private void writePropertyInternal(OutboundRow sink, Object value, boolean isNew,
RelationalPersistentProperty property) {
TypeInformation<?> valueType = ClassTypeInformation.from(value.getClass());
TypeInformation<?> valueType = TypeInformation.of(value.getClass());
if (valueType.isCollectionLike()) {

View File

@@ -16,6 +16,7 @@ import org.springframework.data.r2dbc.mapping.R2dbcSimpleTypeHolder;
* {@link org.springframework.data.mapping.model.SimpleTypeHolder}
*
* @author Mark Paluch
* @author Jens Schauder
* @see CustomConversions
* @see org.springframework.data.mapping.model.SimpleTypeHolder
*/
@@ -33,20 +34,6 @@ public class R2dbcCustomConversions extends CustomConversions {
STORE_CONVERSIONS = StoreConversions.of(R2dbcSimpleTypeHolder.HOLDER, STORE_CONVERTERS);
}
/**
* Create a new {@link R2dbcCustomConversions} instance registering the given converters.
*
* @param converters must not be {@literal null}.
* @deprecated since 1.3, use {@link #of(R2dbcDialect, Object...)} or
* {@link #R2dbcCustomConversions(StoreConversions, Collection)} directly to consider dialect-native
* simple types. Use {@link CustomConversions.StoreConversions#NONE} to omit store-specific converters.
*/
@Deprecated
public R2dbcCustomConversions(Collection<?> converters) {
super(new R2dbcCustomConversionsConfiguration(STORE_CONVERSIONS,
converters instanceof List ? (List<?>) converters : new ArrayList<>(converters)));
}
/**
* Create a new {@link R2dbcCustomConversions} instance registering the given converters.
*

View File

@@ -38,7 +38,7 @@ import org.springframework.data.relational.core.query.CriteriaDefinition;
import org.springframework.data.relational.core.query.CriteriaDefinition.Comparator;
import org.springframework.data.relational.core.query.ValueFunction;
import org.springframework.data.relational.core.sql.*;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.data.util.Pair;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
@@ -392,7 +392,7 @@ public class QueryMapper {
return Parameter.empty(converter.getTargetType(value.getType()));
}
return Parameter.from(convertValue(value.getValue(), ClassTypeInformation.OBJECT));
return Parameter.from(convertValue(value.getValue(), TypeInformation.OBJECT));
}
@Nullable
@@ -408,11 +408,11 @@ public class QueryMapper {
Object first = convertValue(pair.getFirst(),
typeInformation.getActualType() != null ? typeInformation.getRequiredActualType()
: ClassTypeInformation.OBJECT);
: TypeInformation.OBJECT);
Object second = convertValue(pair.getSecond(),
typeInformation.getActualType() != null ? typeInformation.getRequiredActualType()
: ClassTypeInformation.OBJECT);
: TypeInformation.OBJECT);
return Pair.of(first, second);
}
@@ -423,14 +423,14 @@ public class QueryMapper {
for (Object o : (Iterable<?>) value) {
mapped.add(convertValue(o, typeInformation.getActualType() != null ? typeInformation.getRequiredActualType()
: ClassTypeInformation.OBJECT));
: TypeInformation.OBJECT));
}
return mapped;
}
if (value.getClass().isArray()
&& (ClassTypeInformation.OBJECT.equals(typeInformation) || typeInformation.isCollectionLike())) {
&& (TypeInformation.OBJECT.equals(typeInformation) || typeInformation.isCollectionLike())) {
return value;
}
@@ -633,7 +633,7 @@ public class QueryMapper {
}
public TypeInformation<?> getTypeHint() {
return ClassTypeInformation.OBJECT;
return TypeInformation.OBJECT;
}
}
@@ -734,7 +734,7 @@ public class QueryMapper {
}
if (this.property.getType().isPrimitive()) {
return ClassTypeInformation.from(ClassUtils.resolvePrimitiveIfNecessary(this.property.getType()));
return TypeInformation.of(ClassUtils.resolvePrimitiveIfNecessary(this.property.getType()));
}
if (this.property.getType().isArray()) {
@@ -743,7 +743,7 @@ public class QueryMapper {
if (this.property.getType().isInterface()
|| (java.lang.reflect.Modifier.isAbstract(this.property.getType().getModifiers()))) {
return ClassTypeInformation.OBJECT;
return TypeInformation.OBJECT;
}
return this.property.getTypeInformation();

View File

@@ -28,11 +28,11 @@ import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.relational.repository.Lock;
import org.springframework.data.r2dbc.repository.Modifying;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
import org.springframework.data.relational.repository.Lock;
import org.springframework.data.relational.repository.query.RelationalEntityMetadata;
import org.springframework.data.relational.repository.query.RelationalParameters;
import org.springframework.data.relational.repository.query.SimpleRelationalEntityMetadata;
@@ -41,7 +41,6 @@ import org.springframework.data.repository.query.Parameter;
import org.springframework.data.repository.query.QueryMethod;
import org.springframework.data.repository.util.ReactiveWrapperConverters;
import org.springframework.data.repository.util.ReactiveWrappers;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.Lazy;
import org.springframework.data.util.ReflectionUtils;
import org.springframework.data.util.TypeInformation;
@@ -59,10 +58,10 @@ import org.springframework.util.ClassUtils;
public class R2dbcQueryMethod extends QueryMethod {
@SuppressWarnings("rawtypes") //
private static final ClassTypeInformation<Page> PAGE_TYPE = ClassTypeInformation.from(Page.class);
private static final TypeInformation<Page> PAGE_TYPE = TypeInformation.of(Page.class);
@SuppressWarnings("rawtypes") //
private static final ClassTypeInformation<Slice> SLICE_TYPE = ClassTypeInformation.from(Slice.class);
private static final TypeInformation<Slice> SLICE_TYPE = TypeInformation.of(Slice.class);
private final MappingContext<? extends RelationalPersistentEntity<?>, ? extends RelationalPersistentProperty> mappingContext;
private final Optional<Query> query;
@@ -91,7 +90,7 @@ public class R2dbcQueryMethod extends QueryMethod {
if (hasParameterOfType(method, Pageable.class)) {
TypeInformation<?> returnType = ClassTypeInformation.fromReturnTypeOf(method);
TypeInformation<?> returnType = TypeInformation.fromReturnTypeOf(method);
boolean multiWrapper = ReactiveWrappers.isMultiValueType(returnType.getType());
boolean singleWrapperWithWrappedPageableResult = ReactiveWrappers.isSingleValueType(returnType.getType())

View File

@@ -23,8 +23,6 @@ import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.Value;
import org.springframework.data.relational.core.sql.LockMode;
import org.springframework.data.relational.repository.Lock;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Hooks;
import reactor.core.publisher.Mono;
@@ -39,16 +37,17 @@ import javax.sql.DataSource;
import org.assertj.core.api.Condition;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.data.annotation.PersistenceCreator;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
import org.springframework.data.r2dbc.testing.R2dbcIntegrationTestSupport;
import org.springframework.data.relational.core.mapping.Table;
import org.springframework.data.relational.core.sql.LockMode;
import org.springframework.data.relational.repository.Lock;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -479,7 +478,7 @@ public abstract class AbstractR2dbcRepositoryIntegrationTests extends R2dbcInteg
Integer manual;
boolean flag;
@PersistenceConstructor
@PersistenceCreator
LegoSet(Integer id, String name, Integer manual) {
super(id);
this.name = name;

View File

@@ -35,7 +35,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.data.annotation.PersistenceCreator;
import org.springframework.data.r2dbc.testing.R2dbcIntegrationTestSupport;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;
@@ -126,13 +126,15 @@ public abstract class AbstractR2dbcRepositoryWithMixedCaseNamesIntegrationTests
@NoArgsConstructor
public static class LegoSet {
@Nullable @Column("Id") @Id Integer id;
@Nullable
@Column("Id")
@Id Integer id;
@Column("Name") String name;
@Column("Manual") Integer manual;
@PersistenceConstructor
@PersistenceCreator
LegoSet(@Nullable Integer id, String name, Integer manual) {
this.id = id;
this.name = name;

View File

@@ -26,7 +26,7 @@ import org.springframework.core.env.Environment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.data.relational.core.mapping.Table;
import org.springframework.data.repository.CrudRepository;
@@ -43,14 +43,13 @@ import org.springframework.data.repository.reactive.ReactiveCrudRepository;
*/
class R2dbcRepositoryConfigurationExtensionUnitTests {
private final StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(Config.class, true);
private final AnnotationMetadata metadata = AnnotationMetadata.introspect(Config.class);
private final ResourceLoader loader = new PathMatchingResourcePatternResolver();
private final Environment environment = new StandardEnvironment();
private final BeanDefinitionRegistry registry = new DefaultListableBeanFactory();
private final RepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(
metadata,
EnableR2dbcRepositories.class, loader, environment, registry);
metadata, EnableR2dbcRepositories.class, loader, environment, registry);
@Test // gh-13
void isStrictMatchIfDomainTypeIsAnnotatedWithDocument() {

View File

@@ -85,8 +85,7 @@ public abstract class ExternalDatabase implements BeforeAllCallback {
public void beforeAll(ExtensionContext context) {
if (!checkValidity()) {
throw new TestAbortedException(
String.format("Cannot connect to %s. Skipping tests.", this));
throw new TestAbortedException(String.format("Cannot connect to %s. Skipping tests.", this));
}
}
@@ -134,7 +133,7 @@ public abstract class ExternalDatabase implements BeforeAllCallback {
*/
public static ProvidedDatabaseBuilder builder(JdbcDatabaseContainer container) {
return builder().hostname(container.getContainerIpAddress()) //
return builder().hostname(container.getHost()) //
.port(container.getFirstMappedPort()) //
.username(container.getUsername()) //
.password(container.getPassword()) //

View File

@@ -47,7 +47,7 @@ public class OracleConnectionFactoryProviderWrapper implements ConnectionFactory
try {
return (ConnectionFactoryProvider) Class.forName("oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl")
.newInstance();
.getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
ReflectionUtils.handleReflectionException(e);
}