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
This commit is contained in:
Jens Schauder
2022-08-10 14:52:10 +02:00
parent 07ade67862
commit 2a8f62245b
21 changed files with 13 additions and 322 deletions

View File

@@ -167,12 +167,6 @@ public class BasicJdbcConverter extends BasicRelationalConverter implements Jdbc
return JdbcUtil.targetSqlTypeFor(getColumnType(property));
}
@Override
@Deprecated
public int getSqlType(RelationalPersistentProperty property) {
return JdbcUtil.sqlTypeFor(getColumnType(property));
}
@Override
public Class<?> getColumnType(RelationalPersistentProperty property) {
return doGetColumnType(property);
@@ -261,12 +255,6 @@ public class BasicJdbcConverter extends BasicRelationalConverter implements Jdbc
return customWriteTarget.isPresent() && customWriteTarget.get().isAssignableFrom(JdbcValue.class);
}
@Override
@Deprecated
public JdbcValue writeJdbcValue(@Nullable Object value, Class<?> columnType, int sqlType) {
return writeJdbcValue(value, columnType, JdbcUtil.jdbcTypeFor(sqlType));
}
/*
* (non-Javadoc)
* @see org.springframework.data.jdbc.core.convert.JdbcConverter#writeValue(java.lang.Object, java.lang.Class, int)

View File

@@ -52,11 +52,6 @@ public class CascadingDataAccessStrategy implements DataAccessStrategy {
this.strategies = new ArrayList<>(strategies);
}
@Override
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
return collect(das -> das.insert(instance, domainType, identifier));
}
@Override
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, IdValueSource idValueSource) {
return collect(das -> das.insert(instance, domainType, identifier, idValueSource));

View File

@@ -44,24 +44,6 @@ import org.springframework.lang.Nullable;
*/
public interface DataAccessStrategy extends RelationResolver {
/**
* Inserts the data of a single entity. Referenced entities don't get handled.
*
* @param <T> the type of the instance.
* @param instance the instance to be stored. Must not be {@code null}.
* @param domainType the type of the instance. Must not be {@code null}.
* @param identifier information about data that needs to be considered for the insert but which is not part of the
* entity. Namely, references back to a parent entity and key/index columns for entities that are stored in a
* {@link Map} or {@link List}.
* @return the id generated by the database if any.
* @since 1.1
* @deprecated since 2.4, use {@link #insert(Object, Class, Identifier, IdValueSource)}. This will no longer insert as
* expected when the id property of the instance is pre-populated.
*/
@Nullable
@Deprecated
<T> Object insert(T instance, Class<T> domainType, Identifier identifier);
/**
* Inserts the data of a single entity. Referenced entities don't get handled.
*

View File

@@ -98,13 +98,6 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
this.insertStrategyFactory = insertStrategyFactory;
}
@Override
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
RelationalPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(domainType);
return insert(instance, domainType, identifier, IdValueSource.forInstance(instance, persistentEntity));
}
@Override
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, IdValueSource idValueSource) {

View File

@@ -43,11 +43,6 @@ public class DelegatingDataAccessStrategy implements DataAccessStrategy {
private DataAccessStrategy delegate;
@Override
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
return delegate.insert(instance, domainType, identifier);
}
@Override
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, IdValueSource idValueSource) {
return delegate.insert(instance, domainType, identifier, idValueSource);

View File

@@ -1,4 +1,4 @@
/*
/*
* Copyright 2019-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,17 +35,6 @@ import org.springframework.lang.Nullable;
*/
public interface JdbcConverter extends RelationalConverter {
/**
* Convert a property value into a {@link JdbcValue} that contains the converted value and information how to bind it
* to JDBC parameters.
*
* @param value a value as it is used in the object model. May be {@code null}.
* @param type {@literal Class} into which the value is to be converted. Must not be {@code null}.
* @param sqlType the type constant from {@link java.sql.Types} to be used if non is specified by a converter.
* @return The converted value wrapped in a {@link JdbcValue}. Guaranteed to be not {@literal null}.
*/
JdbcValue writeJdbcValue(@Nullable Object value, Class<?> type, int sqlType);
/**
* Convert a property value into a {@link JdbcValue} that contains the converted value and information how to bind it
* to JDBC parameters.
@@ -99,8 +88,4 @@ public interface JdbcConverter extends RelationalConverter {
* @since 2.0
*/
SQLType getTargetSqlType(RelationalPersistentProperty property);
@Deprecated
int getSqlType(RelationalPersistentProperty property);
}

View File

@@ -27,25 +27,10 @@ import org.springframework.data.relational.core.mapping.RelationalPersistentProp
* Extension to {@link BasicRelationalPersistentProperty}.
*
* @author Mark Paluch
* @author Jens Schauder
*/
public class BasicJdbcPersistentProperty extends BasicRelationalPersistentProperty {
/**
* Creates a new {@link BasicJdbcPersistentProperty}.
*
* @param property must not be {@literal null}.
* @param owner must not be {@literal null}.
* @param simpleTypeHolder must not be {@literal null}.
* @param context must not be {@literal null}
* @deprecated since 2.0, use
* {@link #BasicJdbcPersistentProperty(Property, PersistentEntity, SimpleTypeHolder, NamingStrategy)}.
*/
@Deprecated
public BasicJdbcPersistentProperty(Property property, PersistentEntity<?, RelationalPersistentProperty> owner,
SimpleTypeHolder simpleTypeHolder, RelationalMappingContext context) {
super(property, owner, simpleTypeHolder, context);
}
/**
* Creates a new {@link BasicJdbcPersistentProperty}.
*
@@ -64,9 +49,4 @@ public class BasicJdbcPersistentProperty extends BasicRelationalPersistentProper
public boolean isAssociation() {
return super.isAssociation() || AggregateReference.class.isAssignableFrom(getRawType());
}
@Override
public boolean isReference() {
return isAssociation();
}
}

View File

@@ -144,15 +144,6 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
this.namespaceStrategy = namespaceStrategy;
}
@Override
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
MyBatisContext myBatisContext = new MyBatisContext(identifier, instance, domainType);
sqlSession().insert(namespace(domainType) + ".insert", myBatisContext);
return myBatisContext.getId();
}
@Override
public <T> Object insert(T instance, Class<T> domainType, Identifier identifier, IdValueSource idValueSource) {

View File

@@ -24,7 +24,6 @@ import org.springframework.data.jdbc.core.convert.JdbcConverter;
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.jdbc.mybatis.MyBatisDataAccessStrategy;
import org.springframework.data.relational.core.dialect.Dialect;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
/**

View File

@@ -87,27 +87,6 @@ public final class JdbcUtil {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
/**
* Returns the {@link Types} value suitable for passing a value of the provided type to a
* {@link java.sql.PreparedStatement}.
*
* @param type The type of value to be bound to a {@link java.sql.PreparedStatement}.
* @return One of the values defined in {@link Types} or {@link JdbcUtils#TYPE_UNKNOWN}.
* @deprecated use {@link #targetSqlTypeFor(Class)} instead.
*/
@Deprecated
public static int sqlTypeFor(Class<?> type) {
Assert.notNull(type, "Type must not be null");
return sqlTypeMappings.keySet().stream() //
.filter(k -> k.isAssignableFrom(type)) //
.findFirst() //
.map(sqlTypeMappings::get) //
.map(SQLType::getVendorTypeNumber)
.orElse(JdbcUtils.TYPE_UNKNOWN);
}
/**
* Returns the {@link SQLType} value suitable for passing a value of the provided type to JDBC driver.
*
@@ -124,49 +103,4 @@ public final class JdbcUtil {
.map(sqlTypeMappings::get) //
.orElse(JdbcUtil.TYPE_UNKNOWN);
}
/**
* Converts a {@link JDBCType} to an {@code int} value as defined in {@link Types}.
*
* @param jdbcType value to be converted. May be {@literal null}.
* @return One of the values defined in {@link Types} or {@link JdbcUtils#TYPE_UNKNOWN}.
* @deprecated there is no replacement.
*/
@Deprecated
public static int sqlTypeFor(@Nullable SQLType jdbcType) {
return jdbcType == null ? JdbcUtils.TYPE_UNKNOWN : jdbcType.getVendorTypeNumber();
}
/**
* Converts a value defined in {@link Types} into a {@link JDBCType} instance or {@literal null} if the value is
* {@link JdbcUtils#TYPE_UNKNOWN}
*
* @param sqlType One of the values defined in {@link Types} or {@link JdbcUtils#TYPE_UNKNOWN}.
* @return a matching {@link JDBCType} instance or {@literal null}.
* @deprecated This is now a noop
*/
@Nullable
@Deprecated
public static SQLType jdbcTypeFor(int sqlType) {
if (sqlType == JdbcUtils.TYPE_UNKNOWN) {
return null;
}
return JDBCType.valueOf(sqlType);
}
/**
* Returns the {@link JDBCType} suitable for passing a value of the provided type to a
* {@link java.sql.PreparedStatement}.
*
* @param type The type of value to be bound to a {@link java.sql.PreparedStatement}.
* @return a matching {@link JDBCType} instance or {@literal null}.
* @deprecated Use {@link #targetSqlTypeFor(Class)} instead.
*/
@Deprecated
public static SQLType jdbcTypeFor(Class<?> type) {
return targetSqlTypeFor(type);
}
}

View File

@@ -77,12 +77,6 @@ public class NamingStrategyUnitTests {
assertThat(target.getSchema()).isEqualTo("");
}
@Test // DATAJDBC-184
public void getQualifiedTableName() {
assertThat(target.getQualifiedTableName(persistentEntity.getType())).isEqualTo("dummy_entity");
}
@Data
private static class DummyEntity {