Skip to content

Commit f326897

Browse files
committed
Removed deprecations.
Removed deprecated API and usasage of deprecated API. Closes #1340
1 parent 98ef3df commit f326897

File tree

20 files changed

+72
-94
lines changed

20 files changed

+72
-94
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverter.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springframework.data.jdbc.core.mapping.AggregateReference;
3434
import org.springframework.data.jdbc.core.mapping.JdbcValue;
3535
import org.springframework.data.jdbc.support.JdbcUtil;
36+
import org.springframework.data.mapping.InstanceCreatorMetadata;
3637
import org.springframework.data.mapping.Parameter;
3738
import org.springframework.data.mapping.PersistentPropertyAccessor;
3839
import org.springframework.data.mapping.PersistentPropertyPath;
@@ -50,7 +51,7 @@
5051
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
5152
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
5253
import org.springframework.data.relational.core.sql.IdentifierProcessing;
53-
import org.springframework.data.util.ClassTypeInformation;
54+
import org.springframework.data.util.TypeInformation;
5455
import org.springframework.data.util.TypeInformation;
5556
import org.springframework.lang.Nullable;
5657
import org.springframework.util.Assert;
@@ -267,7 +268,7 @@ public JdbcValue writeJdbcValue(@Nullable Object value, Class<?> columnType, SQL
267268
return jdbcValue;
268269
}
269270

270-
Object convertedValue = writeValue(value, ClassTypeInformation.from(columnType));
271+
Object convertedValue = writeValue(value, TypeInformation.of(columnType));
271272

272273
if (convertedValue == null || !convertedValue.getClass().isArray()) {
273274

@@ -293,7 +294,7 @@ private JdbcValue tryToConvertToJdbcValue(@Nullable Object value) {
293294

294295
if (canWriteAsJdbcValue(value)) {
295296

296-
Object converted = writeValue(value, ClassTypeInformation.from(JdbcValue.class));
297+
Object converted = writeValue(value, TypeInformation.of(JdbcValue.class));
297298
if (converted instanceof JdbcValue) {
298299
return (JdbcValue) converted;
299300
}
@@ -414,11 +415,11 @@ T mapRow() {
414415
private T populateProperties(T instance, @Nullable Object idValue) {
415416

416417
PersistentPropertyAccessor<T> propertyAccessor = getPropertyAccessor(entity, instance);
417-
PreferredConstructor<T, RelationalPersistentProperty> persistenceConstructor = entity.getPersistenceConstructor();
418+
InstanceCreatorMetadata<RelationalPersistentProperty> creatorMetadata = entity.getInstanceCreatorMetadata();
418419

419420
entity.doWithAll(property -> {
420421

421-
if (persistenceConstructor != null && persistenceConstructor.isConstructorParameter(property)) {
422+
if (creatorMetadata != null && creatorMetadata.isCreatorParameter(property)) {
422423
return;
423424
}
424425

@@ -548,10 +549,10 @@ private Object readEntityFrom(RelationalPersistentProperty property) {
548549

549550
private T createInstanceInternal(@Nullable Object idValue) {
550551

551-
PreferredConstructor<T, RelationalPersistentProperty> persistenceConstructor = entity.getPersistenceConstructor();
552+
InstanceCreatorMetadata<RelationalPersistentProperty> creatorMetadata = entity.getInstanceCreatorMetadata();
552553
ParameterValueProvider<RelationalPersistentProperty> provider;
553554

554-
if (persistenceConstructor != null && persistenceConstructor.hasParameters()) {
555+
if (creatorMetadata != null && creatorMetadata.hasParameters()) {
555556

556557
SpELExpressionEvaluator expressionEvaluator = new DefaultSpELExpressionEvaluator(accessor, spELContext);
557558
provider = new SpELExpressionParameterValueProvider<>(expressionEvaluator, getConversionService(),

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/QueryMapper.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import org.springframework.data.relational.core.query.CriteriaDefinition.Comparator;
4242
import org.springframework.data.relational.core.query.ValueFunction;
4343
import org.springframework.data.relational.core.sql.*;
44-
import org.springframework.data.util.ClassTypeInformation;
44+
import org.springframework.data.util.TypeInformation;
4545
import org.springframework.data.util.Pair;
4646
import org.springframework.data.util.TypeInformation;
4747
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
@@ -441,11 +441,11 @@ protected Object convertValue(@Nullable Object value, TypeInformation<?> typeInf
441441

442442
Object first = convertValue(pair.getFirst(), typeInformation.getActualType() != null //
443443
? typeInformation.getRequiredActualType()
444-
: ClassTypeInformation.OBJECT);
444+
: TypeInformation.OBJECT);
445445

446446
Object second = convertValue(pair.getSecond(), typeInformation.getActualType() != null //
447447
? typeInformation.getRequiredActualType()
448-
: ClassTypeInformation.OBJECT);
448+
: TypeInformation.OBJECT);
449449

450450
return Pair.of(first, second);
451451
}
@@ -457,14 +457,14 @@ protected Object convertValue(@Nullable Object value, TypeInformation<?> typeInf
457457
for (Object o : (Iterable<?>) value) {
458458

459459
mapped.add(convertValue(o, typeInformation.getActualType() != null ? typeInformation.getRequiredActualType()
460-
: ClassTypeInformation.OBJECT));
460+
: TypeInformation.OBJECT));
461461
}
462462

463463
return mapped;
464464
}
465465

466466
if (value.getClass().isArray()
467-
&& (ClassTypeInformation.OBJECT.equals(typeInformation) || typeInformation.isCollectionLike())) {
467+
&& (TypeInformation.OBJECT.equals(typeInformation) || typeInformation.isCollectionLike())) {
468468
return value;
469469
}
470470

@@ -587,7 +587,7 @@ private Condition createCondition(Column column, @Nullable Object mappedValue, S
587587

588588
private Expression bindBoolean(Column column, MapSqlParameterSource parameterSource, boolean value) {
589589

590-
Object converted = converter.writeValue(value, ClassTypeInformation.OBJECT);
590+
Object converted = converter.writeValue(value, TypeInformation.OBJECT);
591591
return bind(converted, JDBCType.BIT, parameterSource, column.getName().getReference());
592592
}
593593

@@ -678,7 +678,7 @@ public SqlIdentifier getMappedColumnName() {
678678
}
679679

680680
public TypeInformation<?> getTypeHint() {
681-
return ClassTypeInformation.OBJECT;
681+
return TypeInformation.OBJECT;
682682
}
683683

684684
public SQLType getSqlType() {
@@ -808,7 +808,7 @@ public TypeInformation<?> getTypeHint() {
808808
}
809809

810810
if (this.property.getType().isPrimitive()) {
811-
return ClassTypeInformation.from(ClassUtils.resolvePrimitiveIfNecessary(this.property.getType()));
811+
return TypeInformation.of(ClassUtils.resolvePrimitiveIfNecessary(this.property.getType()));
812812
}
813813

814814
if (this.property.getType().isArray()) {

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/StringBasedJdbcQuery.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.springframework.util.Assert;
4646
import org.springframework.util.ClassUtils;
4747
import org.springframework.util.ObjectUtils;
48-
import org.springframework.util.StringUtils;
4948

5049
/**
5150
* A query to be executed based on a repository method, it's annotated SQL query and the arguments provided to the
@@ -211,7 +210,7 @@ ResultSetExtractor<Object> determineResultSetExtractor(@Nullable RowMapper<Objec
211210

212211
String resultSetExtractorRef = queryMethod.getResultSetExtractorRef();
213212

214-
if (!StringUtils.isEmpty(resultSetExtractorRef)) {
213+
if (!ObjectUtils.isEmpty(resultSetExtractorRef)) {
215214

216215
Assert.notNull(beanFactory, "When a ResultSetExtractorRef is specified the BeanFactory must not be null");
217216

@@ -253,7 +252,7 @@ RowMapper<Object> determineRowMapper(@Nullable RowMapper<?> defaultMapper) {
253252

254253
String rowMapperRef = queryMethod.getRowMapperRef();
255254

256-
if (!StringUtils.isEmpty(rowMapperRef)) {
255+
if (!ObjectUtils.isEmpty(rowMapperRef)) {
257256

258257
Assert.notNull(beanFactory, "When a RowMapperRef is specified the BeanFactory must not be null");
259258

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverterUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
4545
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
4646
import org.springframework.data.relational.core.sql.IdentifierProcessing;
47-
import org.springframework.data.util.ClassTypeInformation;
47+
import org.springframework.data.util.TypeInformation;
4848

4949
/**
5050
* Unit tests for {@link BasicJdbcConverter}.
@@ -147,7 +147,7 @@ private void checkConversionToTimestampAndBack(SoftAssertions softly, Relational
147147

148148
RelationalPersistentProperty property = persistentEntity.getRequiredPersistentProperty(propertyName);
149149

150-
Object converted = converter.writeValue(value, ClassTypeInformation.from(converter.getColumnType(property)));
150+
Object converted = converter.writeValue(value, TypeInformation.of(converter.getColumnType(property)));
151151
Object convertedBack = converter.readValue(converted, property.getTypeInformation());
152152

153153
softly.assertThat(convertedBack).describedAs(propertyName).isEqualTo(value);

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/BasicRelationalConverterAggregateReferenceUnitTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020

2121
import org.assertj.core.api.Assertions;
2222
import org.junit.jupiter.api.Test;
23-
2423
import org.springframework.data.annotation.Id;
2524
import org.springframework.data.jdbc.core.mapping.AggregateReference;
2625
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
2726
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
2827
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
29-
import org.springframework.data.util.ClassTypeInformation;
28+
import org.springframework.data.util.TypeInformation;
3029

3130
/**
3231
* Unit tests for the handling of {@link AggregateReference}s in the
@@ -59,7 +58,7 @@ public void convertsFromAggregateReference() {
5958

6059
AggregateReference<Object, Integer> reference = AggregateReference.to(23);
6160

62-
Object writeValue = converter.writeValue(reference, ClassTypeInformation.from(converter.getColumnType(property)));
61+
Object writeValue = converter.writeValue(reference, TypeInformation.of(converter.getColumnType(property)));
6362

6463
Assertions.assertThat(writeValue).isEqualTo(23L);
6564
}

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/EntityRowMapperUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import org.mockito.invocation.InvocationOnMock;
5050
import org.mockito.stubbing.Answer;
5151
import org.springframework.data.annotation.Id;
52-
import org.springframework.data.annotation.PersistenceConstructor;
52+
import org.springframework.data.annotation.PersistenceCreator;
5353
import org.springframework.data.annotation.Transient;
5454
import org.springframework.data.jdbc.core.mapping.AggregateReference;
5555
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
@@ -755,7 +755,7 @@ static class MixedProperties {
755755
String two;
756756
final String three;
757757

758-
@PersistenceConstructor
758+
@PersistenceCreator
759759
MixedProperties(String one) {
760760
this.one = one;
761761
this.three = "unset";

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/JdbcRepositoryConfigExtensionUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.springframework.core.env.StandardEnvironment;
2727
import org.springframework.core.io.ResourceLoader;
2828
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
29-
import org.springframework.core.type.StandardAnnotationMetadata;
29+
import org.springframework.core.type.AnnotationMetadata;
3030
import org.springframework.data.relational.core.mapping.Table;
3131
import org.springframework.data.repository.Repository;
3232
import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource;
@@ -40,13 +40,13 @@
4040
*/
4141
public class JdbcRepositoryConfigExtensionUnitTests {
4242

43-
StandardAnnotationMetadata metadata = new StandardAnnotationMetadata(Config.class, true);
43+
AnnotationMetadata metadata = AnnotationMetadata.introspect(Config.class);
4444
ResourceLoader loader = new PathMatchingResourcePatternResolver();
4545
Environment environment = new StandardEnvironment();
4646
BeanDefinitionRegistry registry = new DefaultListableBeanFactory();
4747

4848
RepositoryConfigurationSource configurationSource = new AnnotationRepositoryConfigurationSource(metadata,
49-
EnableJdbcRepositories.class, loader, environment, registry);
49+
EnableJdbcRepositories.class, loader, environment, registry, null);
5050

5151
@Test // DATAJPA-437
5252
public void isStrictMatchOnlyIfDomainTypeIsAnnotatedWithDocument() {

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/query/JdbcQueryMethodUnitTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.springframework.data.repository.core.NamedQueries;
3333
import org.springframework.data.repository.core.RepositoryMetadata;
3434
import org.springframework.data.repository.core.support.PropertiesBasedNamedQueries;
35-
import org.springframework.data.util.ClassTypeInformation;
35+
import org.springframework.data.util.TypeInformation;
3636
import org.springframework.jdbc.core.RowMapper;
3737

3838
/**
@@ -67,7 +67,7 @@ public void before() {
6767

6868
metadata = mock(RepositoryMetadata.class);
6969
doReturn(String.class).when(metadata).getReturnedDomainClass(any(Method.class));
70-
doReturn(ClassTypeInformation.from(String.class)).when(metadata).getReturnType(any(Method.class));
70+
doReturn(TypeInformation.of(String.class)).when(metadata).getReturnType(any(Method.class));
7171
}
7272

7373
@Test // DATAJDBC-165

spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/support/JdbcQueryLookupStrategyUnitTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import org.junit.jupiter.api.BeforeEach;
2727
import org.junit.jupiter.api.Test;
28-
2928
import org.junit.jupiter.params.ParameterizedTest;
3029
import org.junit.jupiter.params.provider.Arguments;
3130
import org.junit.jupiter.params.provider.MethodSource;
@@ -42,7 +41,7 @@
4241
import org.springframework.data.repository.core.RepositoryMetadata;
4342
import org.springframework.data.repository.query.QueryLookupStrategy;
4443
import org.springframework.data.repository.query.RepositoryQuery;
45-
import org.springframework.data.util.ClassTypeInformation;
44+
import org.springframework.data.util.TypeInformation;
4645
import org.springframework.jdbc.core.RowMapper;
4746
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
4847
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
@@ -77,7 +76,7 @@ void setup() {
7776
this.metadata = mock(RepositoryMetadata.class);
7877

7978
doReturn(NumberFormat.class).when(metadata).getReturnedDomainClass(any(Method.class));
80-
doReturn(ClassTypeInformation.from(NumberFormat.class)).when(metadata).getReturnType(any(Method.class));
79+
doReturn(TypeInformation.of(NumberFormat.class)).when(metadata).getReturnType(any(Method.class));
8180
}
8281

8382
@Test // DATAJDBC-166

spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/convert/MappingR2dbcConverter.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import org.springframework.data.relational.core.dialect.ArrayColumns;
5151
import org.springframework.data.relational.core.mapping.RelationalPersistentEntity;
5252
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty;
53-
import org.springframework.data.util.ClassTypeInformation;
5453
import org.springframework.data.util.TypeInformation;
5554
import org.springframework.lang.Nullable;
5655
import org.springframework.r2dbc.core.Parameter;
@@ -107,7 +106,7 @@ public <R> R read(Class<R> type, Row row) {
107106
@Override
108107
public <R> R read(Class<R> type, Row row, @Nullable RowMetadata metadata) {
109108

110-
TypeInformation<? extends R> typeInfo = ClassTypeInformation.from(type);
109+
TypeInformation<? extends R> typeInfo = TypeInformation.of(type);
111110
Class<? extends R> rawType = typeInfo.getType();
112111

113112
if (Row.class.isAssignableFrom(rawType)) {
@@ -132,7 +131,7 @@ private <R> R read(RelationalPersistentEntity<R> entity, Row row, @Nullable RowM
132131

133132
for (RelationalPersistentProperty property : entity) {
134133

135-
if (entity.isConstructorArgument(property)) {
134+
if (entity.isCreatorArgument(property)) {
136135
continue;
137136
}
138137

@@ -185,12 +184,10 @@ private Object readFrom(Row row, @Nullable RowMetadata metadata, RelationalPersi
185184
return readValue(value, property.getTypeInformation());
186185

187186
} catch (Exception o_O) {
188-
throw new MappingException(String.format("Could not read property %s from column %s", property, identifier),
189-
o_O);
187+
throw new MappingException(String.format("Could not read property %s from column %s", property, identifier), o_O);
190188
}
191189
}
192190

193-
194191
public Object readValue(@Nullable Object value, TypeInformation<?> type) {
195192

196193
if (null == value) {
@@ -224,7 +221,7 @@ private Object readCollectionOrArray(Collection<?> source, TypeInformation<?> ta
224221

225222
TypeInformation<?> componentType = targetType.getComponentType() != null //
226223
? targetType.getComponentType() //
227-
: ClassTypeInformation.OBJECT;
224+
: TypeInformation.OBJECT;
228225
Class<?> rawComponentType = componentType.getType();
229226

230227
Collection<Object> items = targetType.getType().isArray() //
@@ -302,7 +299,7 @@ private <S> S readEntityFrom(Row row, @Nullable RowMetadata metadata, Persistent
302299
getConversionService());
303300

304301
for (RelationalPersistentProperty p : entity) {
305-
if (!entity.isConstructorArgument(property)) {
302+
if (!entity.isCreatorArgument(property)) {
306303
propertyAccessor.setProperty(p, readFrom(row, metadata, p, prefix));
307304
}
308305
}
@@ -405,7 +402,7 @@ private void writeSimpleInternal(OutboundRow sink, Object value, boolean isNew,
405402
private void writePropertyInternal(OutboundRow sink, Object value, boolean isNew,
406403
RelationalPersistentProperty property) {
407404

408-
TypeInformation<?> valueType = ClassTypeInformation.from(value.getClass());
405+
TypeInformation<?> valueType = TypeInformation.of(value.getClass());
409406

410407
if (valueType.isCollectionLike()) {
411408

0 commit comments

Comments
 (0)