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 {

View File

@@ -27,6 +27,7 @@ import org.springframework.util.Assert;
*
* @author Mark Paluch
* @author Mikhail Polivakha
* @author Jens Schauder
* @since 1.1
*/
public class RenderContextFactory {
@@ -106,11 +107,6 @@ public class RenderContextFactory {
return renderingDialect.getIdentifierProcessing();
}
@Override
public SelectRenderContext getSelect() {
return getSelectRenderContext();
}
@Override
public SelectRenderContext getSelectRenderContext() {
return selectRenderContext;

View File

@@ -136,11 +136,6 @@ public class BasicRelationalPersistentProperty extends AnnotationBasedPersistent
return super.isEntity() && !isAssociation();
}
@Override
public boolean isReference() {
return false;
}
@Override
public SqlIdentifier getColumnName() {
return columnName.get();

View File

@@ -26,6 +26,7 @@ import org.springframework.util.ConcurrentReferenceHashMap;
* A {@link NamingStrategy} to cache the results of the target one.
*
* @author Oliver Drotbohm
* @author Jens Schauder
* @since 1.1
*/
class CachingNamingStrategy implements NamingStrategy {
@@ -57,12 +58,6 @@ class CachingNamingStrategy implements NamingStrategy {
return keyColumns.computeIfAbsent(property, delegate::getKeyColumn);
}
@Override
@Deprecated
public String getQualifiedTableName(Class<?> type) {
return qualifiedTableNames.computeIfAbsent(type, delegate::getQualifiedTableName);
}
@Override
public String getTableName(Class<?> type) {
return tableNames.computeIfAbsent(type, delegate::getTableName);

View File

@@ -72,17 +72,6 @@ public interface NamingStrategy {
return ParsingUtils.reconcatenateCamelCase(property.getName(), "_");
}
/**
* @param type
* @return
* @deprecated since 2.0. The method returns a concatenated schema with table name which conflicts with escaping. Use
* rather {@link #getTableName(Class)} and {@link #getSchema()} independently
*/
@Deprecated
default String getQualifiedTableName(Class<?> type) {
return this.getSchema() + (this.getSchema().equals("") ? "" : ".") + this.getTableName(type);
}
/**
* For a reference A -&gt; B this is the name in the table for B which references A.
*

View File

@@ -28,13 +28,6 @@ import org.springframework.lang.Nullable;
*/
public interface RelationalPersistentProperty extends PersistentProperty<RelationalPersistentProperty> {
/**
* @deprecated since 2.2, in favor of {@link #isAssociation()}
* @return
*/
@Deprecated
boolean isReference();
/**
* Returns the name of the column backing this property.
*
@@ -68,7 +61,7 @@ public interface RelationalPersistentProperty extends PersistentProperty<Relatio
*/
default boolean isEmbedded() {
return false;
};
}
/**
* @return Prefix for embedded columns. If the column is not embedded the return value is null.
@@ -76,7 +69,7 @@ public interface RelationalPersistentProperty extends PersistentProperty<Relatio
@Nullable
default String getEmbeddedPrefix() {
return null;
};
}
/**
* Returns whether an empty embedded object is supposed to be created for this property.

View File

@@ -17,6 +17,8 @@ package org.springframework.data.relational.core.mapping.event;
import org.springframework.data.relational.core.conversion.AggregateChange;
import java.io.Serial;
/**
* Gets published before an aggregate gets converted into a database change, but after the decision was made if an
* insert or an update is to be performed.
@@ -43,6 +45,7 @@ import org.springframework.data.relational.core.conversion.AggregateChange;
*/
public class BeforeConvertEvent<E> extends RelationalEventWithEntity<E> {
@Serial
private static final long serialVersionUID = -5716795164911939224L;
/**
@@ -52,17 +55,4 @@ public class BeforeConvertEvent<E> extends RelationalEventWithEntity<E> {
public BeforeConvertEvent(E instance) {
super(instance);
}
/**
* @param instance the saved entity. Must not be {@literal null}.
* @param change the {@link AggregateChange} encoding the actions to be performed on the database as change. Since
* this event is fired before the conversion the change is actually empty, but contains information if the
* aggregate is considered new in {@link AggregateChange#getKind()}. Must not be {@literal null}.
* @deprecated since 2.1.4, use {@link #BeforeConvertEvent(Object)} as we don't expect an {@link AggregateChange}
* before converting an aggregate.
*/
@Deprecated
public BeforeConvertEvent(E instance, AggregateChange<E> change) {
super(instance);
}
}

View File

@@ -1,76 +0,0 @@
/*
* Copyright 2019-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.relational.core.sql;
/**
* Simple condition consisting of {@link Expression}, {@code comparator} and {@code predicate}.
*
* @author Mark Paluch
* @since 1.1
* @deprecated since 2.2.5 use {@link Comparison} instead.
*/
@Deprecated
public class SimpleCondition extends AbstractSegment implements Condition {
private final Expression expression;
private final String comparator;
private final String predicate;
SimpleCondition(Expression expression, String comparator, String predicate) {
super(expression);
this.expression = expression;
this.comparator = comparator;
this.predicate = predicate;
}
/**
* Creates a simple {@link Condition} given {@code column}, {@code comparator} and {@code predicate}.
*/
public static SimpleCondition create(String column, String comparator, String predicate) {
return new SimpleCondition(new Column(column, null), comparator, predicate);
}
/**
* @return the condition expression (left-hand-side)
* @since 2.0
*/
public Expression getExpression() {
return expression;
}
/**
* @return the comparator.
*/
public String getComparator() {
return comparator;
}
/**
* @return the condition predicate (right-hand-side)
*/
public String getPredicate() {
return predicate;
}
@Override
public String toString() {
return expression + " " + comparator + " " + predicate;
}
}

View File

@@ -23,6 +23,7 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing;
*
* @author Mark Paluch
* @author Mikhail Polivakha
* @author Jens Schauder
* @since 1.1
*/
public interface RenderContext {
@@ -44,17 +45,8 @@ public interface RenderContext {
/**
* @return the {@link SelectRenderContext}.
* @deprecated Use {@link #getInsertRenderContext()} instead.
*/
@Deprecated
SelectRenderContext getSelect();
/**
* @return the {@link SelectRenderContext}.
*/
default SelectRenderContext getSelectRenderContext() {
return getSelect();
}
SelectRenderContext getSelectRenderContext();
/**
* @return the {@link InsertRenderContext}

View File

@@ -23,6 +23,7 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing;
* Default {@link RenderContext} implementation.
*
* @author Mark Paluch
* @author Jens Schauder
* @since 1.1
*/
final class SimpleRenderContext implements RenderContext {
@@ -38,11 +39,6 @@ final class SimpleRenderContext implements RenderContext {
return IdentifierProcessing.NONE;
}
@Override
public SelectRenderContext getSelect() {
return getSelectRenderContext();
}
@Override
public SelectRenderContext getSelectRenderContext() {
return DefaultSelectRenderContext.INSTANCE;
@@ -64,7 +60,7 @@ final class SimpleRenderContext implements RenderContext {
}
enum DefaultSelectRenderContext implements SelectRenderContext {
INSTANCE;
INSTANCE
}
}

View File

@@ -72,21 +72,6 @@ public class NamingStrategyUnitTests {
assertThat(target.getSchema()).isEqualTo("");
}
@Test
public void getQualifiedTableName() {
assertThat(target.getQualifiedTableName(persistentEntity.getType())).isEqualTo("dummy_entity");
NamingStrategy strategy = new NamingStrategy() {
@Override
public String getSchema() {
return "schema";
}
};
assertThat(strategy.getQualifiedTableName(persistentEntity.getType())).isEqualTo("schema.dummy_entity");
}
static class DummyEntity {
@Id int id;