Skip to content

Commit 2a8f622

Browse files
committed
Remove deprecated code.
This removes most currently deprecated code. An exception are various deprecations in Spring Data R2DBC for which it is not obvious how to modify the code that is still using the deprecated API. Original pull request #1304
1 parent 07ade67 commit 2a8f622

File tree

21 files changed

+13
-322
lines changed

21 files changed

+13
-322
lines changed

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,6 @@ public SQLType getTargetSqlType(RelationalPersistentProperty property) {
167167
return JdbcUtil.targetSqlTypeFor(getColumnType(property));
168168
}
169169

170-
@Override
171-
@Deprecated
172-
public int getSqlType(RelationalPersistentProperty property) {
173-
return JdbcUtil.sqlTypeFor(getColumnType(property));
174-
}
175-
176170
@Override
177171
public Class<?> getColumnType(RelationalPersistentProperty property) {
178172
return doGetColumnType(property);
@@ -261,12 +255,6 @@ private boolean canWriteAsJdbcValue(@Nullable Object value) {
261255
return customWriteTarget.isPresent() && customWriteTarget.get().isAssignableFrom(JdbcValue.class);
262256
}
263257

264-
@Override
265-
@Deprecated
266-
public JdbcValue writeJdbcValue(@Nullable Object value, Class<?> columnType, int sqlType) {
267-
return writeJdbcValue(value, columnType, JdbcUtil.jdbcTypeFor(sqlType));
268-
}
269-
270258
/*
271259
* (non-Javadoc)
272260
* @see org.springframework.data.jdbc.core.convert.JdbcConverter#writeValue(java.lang.Object, java.lang.Class, int)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ public CascadingDataAccessStrategy(List<DataAccessStrategy> strategies) {
5252
this.strategies = new ArrayList<>(strategies);
5353
}
5454

55-
@Override
56-
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
57-
return collect(das -> das.insert(instance, domainType, identifier));
58-
}
59-
6055
@Override
6156
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, IdValueSource idValueSource) {
6257
return collect(das -> das.insert(instance, domainType, identifier, idValueSource));

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,6 @@
4444
*/
4545
public interface DataAccessStrategy extends RelationResolver {
4646

47-
/**
48-
* Inserts the data of a single entity. Referenced entities don't get handled.
49-
*
50-
* @param <T> the type of the instance.
51-
* @param instance the instance to be stored. Must not be {@code null}.
52-
* @param domainType the type of the instance. Must not be {@code null}.
53-
* @param identifier information about data that needs to be considered for the insert but which is not part of the
54-
* entity. Namely, references back to a parent entity and key/index columns for entities that are stored in a
55-
* {@link Map} or {@link List}.
56-
* @return the id generated by the database if any.
57-
* @since 1.1
58-
* @deprecated since 2.4, use {@link #insert(Object, Class, Identifier, IdValueSource)}. This will no longer insert as
59-
* expected when the id property of the instance is pre-populated.
60-
*/
61-
@Nullable
62-
@Deprecated
63-
<T> Object insert(T instance, Class<T> domainType, Identifier identifier);
64-
6547
/**
6648
* Inserts the data of a single entity. Referenced entities don't get handled.
6749
*

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,6 @@ public DefaultDataAccessStrategy(SqlGeneratorSource sqlGeneratorSource, Relation
9898
this.insertStrategyFactory = insertStrategyFactory;
9999
}
100100

101-
@Override
102-
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
103-
104-
RelationalPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(domainType);
105-
return insert(instance, domainType, identifier, IdValueSource.forInstance(instance, persistentEntity));
106-
}
107-
108101
@Override
109102
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, IdValueSource idValueSource) {
110103

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ public class DelegatingDataAccessStrategy implements DataAccessStrategy {
4343

4444
private DataAccessStrategy delegate;
4545

46-
@Override
47-
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
48-
return delegate.insert(instance, domainType, identifier);
49-
}
50-
5146
@Override
5247
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, IdValueSource idValueSource) {
5348
return delegate.insert(instance, domainType, identifier, idValueSource);

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright 2019-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,17 +35,6 @@
3535
*/
3636
public interface JdbcConverter extends RelationalConverter {
3737

38-
/**
39-
* Convert a property value into a {@link JdbcValue} that contains the converted value and information how to bind it
40-
* to JDBC parameters.
41-
*
42-
* @param value a value as it is used in the object model. May be {@code null}.
43-
* @param type {@literal Class} into which the value is to be converted. Must not be {@code null}.
44-
* @param sqlType the type constant from {@link java.sql.Types} to be used if non is specified by a converter.
45-
* @return The converted value wrapped in a {@link JdbcValue}. Guaranteed to be not {@literal null}.
46-
*/
47-
JdbcValue writeJdbcValue(@Nullable Object value, Class<?> type, int sqlType);
48-
4938
/**
5039
* Convert a property value into a {@link JdbcValue} that contains the converted value and information how to bind it
5140
* to JDBC parameters.
@@ -99,8 +88,4 @@ public interface JdbcConverter extends RelationalConverter {
9988
* @since 2.0
10089
*/
10190
SQLType getTargetSqlType(RelationalPersistentProperty property);
102-
103-
@Deprecated
104-
int getSqlType(RelationalPersistentProperty property);
105-
10691
}

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/mapping/BasicJdbcPersistentProperty.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,10 @@
2727
* Extension to {@link BasicRelationalPersistentProperty}.
2828
*
2929
* @author Mark Paluch
30+
* @author Jens Schauder
3031
*/
3132
public class BasicJdbcPersistentProperty extends BasicRelationalPersistentProperty {
3233

33-
/**
34-
* Creates a new {@link BasicJdbcPersistentProperty}.
35-
*
36-
* @param property must not be {@literal null}.
37-
* @param owner must not be {@literal null}.
38-
* @param simpleTypeHolder must not be {@literal null}.
39-
* @param context must not be {@literal null}
40-
* @deprecated since 2.0, use
41-
* {@link #BasicJdbcPersistentProperty(Property, PersistentEntity, SimpleTypeHolder, NamingStrategy)}.
42-
*/
43-
@Deprecated
44-
public BasicJdbcPersistentProperty(Property property, PersistentEntity<?, RelationalPersistentProperty> owner,
45-
SimpleTypeHolder simpleTypeHolder, RelationalMappingContext context) {
46-
super(property, owner, simpleTypeHolder, context);
47-
}
48-
4934
/**
5035
* Creates a new {@link BasicJdbcPersistentProperty}.
5136
*
@@ -64,9 +49,4 @@ public BasicJdbcPersistentProperty(Property property, PersistentEntity<?, Relati
6449
public boolean isAssociation() {
6550
return super.isAssociation() || AggregateReference.class.isAssignableFrom(getRawType());
6651
}
67-
68-
@Override
69-
public boolean isReference() {
70-
return isAssociation();
71-
}
7252
}

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,6 @@ public void setNamespaceStrategy(NamespaceStrategy namespaceStrategy) {
144144
this.namespaceStrategy = namespaceStrategy;
145145
}
146146

147-
@Override
148-
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
149-
150-
MyBatisContext myBatisContext = new MyBatisContext(identifier, instance, domainType);
151-
sqlSession().insert(namespace(domainType) + ".insert", myBatisContext);
152-
153-
return myBatisContext.getId();
154-
}
155-
156147
@Override
157148
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, IdValueSource idValueSource) {
158149

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/MyBatisJdbcConfiguration.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
2525
import org.springframework.data.jdbc.mybatis.MyBatisDataAccessStrategy;
2626
import org.springframework.data.relational.core.dialect.Dialect;
27-
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
2827
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
2928

3029
/**

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/support/JdbcUtil.java

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,6 @@ private JdbcUtil() {
8787
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
8888
}
8989

90-
/**
91-
* Returns the {@link Types} value suitable for passing a value of the provided type to a
92-
* {@link java.sql.PreparedStatement}.
93-
*
94-
* @param type The type of value to be bound to a {@link java.sql.PreparedStatement}.
95-
* @return One of the values defined in {@link Types} or {@link JdbcUtils#TYPE_UNKNOWN}.
96-
* @deprecated use {@link #targetSqlTypeFor(Class)} instead.
97-
*/
98-
@Deprecated
99-
public static int sqlTypeFor(Class<?> type) {
100-
101-
Assert.notNull(type, "Type must not be null");
102-
103-
return sqlTypeMappings.keySet().stream() //
104-
.filter(k -> k.isAssignableFrom(type)) //
105-
.findFirst() //
106-
.map(sqlTypeMappings::get) //
107-
.map(SQLType::getVendorTypeNumber)
108-
.orElse(JdbcUtils.TYPE_UNKNOWN);
109-
}
110-
11190
/**
11291
* Returns the {@link SQLType} value suitable for passing a value of the provided type to JDBC driver.
11392
*
@@ -124,49 +103,4 @@ public static SQLType targetSqlTypeFor(Class<?> type) {
124103
.map(sqlTypeMappings::get) //
125104
.orElse(JdbcUtil.TYPE_UNKNOWN);
126105
}
127-
128-
/**
129-
* Converts a {@link JDBCType} to an {@code int} value as defined in {@link Types}.
130-
*
131-
* @param jdbcType value to be converted. May be {@literal null}.
132-
* @return One of the values defined in {@link Types} or {@link JdbcUtils#TYPE_UNKNOWN}.
133-
* @deprecated there is no replacement.
134-
*/
135-
@Deprecated
136-
public static int sqlTypeFor(@Nullable SQLType jdbcType) {
137-
return jdbcType == null ? JdbcUtils.TYPE_UNKNOWN : jdbcType.getVendorTypeNumber();
138-
}
139-
140-
/**
141-
* Converts a value defined in {@link Types} into a {@link JDBCType} instance or {@literal null} if the value is
142-
* {@link JdbcUtils#TYPE_UNKNOWN}
143-
*
144-
* @param sqlType One of the values defined in {@link Types} or {@link JdbcUtils#TYPE_UNKNOWN}.
145-
* @return a matching {@link JDBCType} instance or {@literal null}.
146-
* @deprecated This is now a noop
147-
*/
148-
@Nullable
149-
@Deprecated
150-
public static SQLType jdbcTypeFor(int sqlType) {
151-
152-
if (sqlType == JdbcUtils.TYPE_UNKNOWN) {
153-
return null;
154-
}
155-
156-
return JDBCType.valueOf(sqlType);
157-
}
158-
159-
/**
160-
* Returns the {@link JDBCType} suitable for passing a value of the provided type to a
161-
* {@link java.sql.PreparedStatement}.
162-
*
163-
* @param type The type of value to be bound to a {@link java.sql.PreparedStatement}.
164-
* @return a matching {@link JDBCType} instance or {@literal null}.
165-
* @deprecated Use {@link #targetSqlTypeFor(Class)} instead.
166-
*/
167-
@Deprecated
168-
public static SQLType jdbcTypeFor(Class<?> type) {
169-
170-
return targetSqlTypeFor(type);
171-
}
172106
}

0 commit comments

Comments
 (0)