From d893259d4edd3e65310e03defd65cb5cf6e69455 Mon Sep 17 00:00:00 2001 From: Mikhail2048 Date: Thu, 24 Mar 2022 17:09:01 -0400 Subject: [PATCH] Remove unnecessary parameters after moving of getReference(Identifier Processing). Original pull request #1209 See #1110 --- .../jdbc/core/convert/BasicJdbcConverter.java | 5 ++-- .../convert/DefaultDataAccessStrategy.java | 6 +---- ...dbcBackReferencePropertyValueProvider.java | 10 +++----- .../convert/JdbcPropertyValueProvider.java | 8 ++---- .../jdbc/core/convert/MapEntityRowMapper.java | 7 ++---- .../convert/SqlIdentifierParameterSource.java | 12 ++++----- .../core/convert/SqlParametersFactory.java | 25 +++++++++++-------- .../mybatis/MyBatisDataAccessStrategy.java | 12 ++++++--- .../config/AbstractJdbcConfiguration.java | 2 +- .../support/JdbcRepositoryFactoryBean.java | 3 +-- .../DefaultDataAccessStrategyUnitTests.java | 2 +- .../IdGeneratingBatchInsertStrategyTest.java | 7 +++--- .../IdGeneratingInsertStrategyTest.java | 2 +- .../convert/InsertStrategyFactoryTest.java | 4 +-- ...SqlIdentifierParameterSourceUnitTests.java | 13 +++++----- .../convert/SqlParametersFactoryTest.java | 4 +-- .../SimpleJdbcRepositoryEventsUnitTests.java | 2 +- ...nableJdbcRepositoriesIntegrationTests.java | 2 +- .../data/jdbc/testing/TestConfiguration.java | 2 +- 19 files changed, 58 insertions(+), 70 deletions(-) diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverter.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverter.java index 3a145fae..8f226875 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverter.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/BasicJdbcConverter.java @@ -371,9 +371,8 @@ public class BasicJdbcConverter extends BasicRelationalConverter implements Jdbc this.path = new PersistentPropertyPathExtension(getMappingContext(), this.entity); this.identifier = identifier; this.key = key; - this.propertyValueProvider = new JdbcPropertyValueProvider(identifierProcessing, path, accessor); - this.backReferencePropertyValueProvider = new JdbcBackReferencePropertyValueProvider(identifierProcessing, path, - accessor); + this.propertyValueProvider = new JdbcPropertyValueProvider(path, accessor); + this.backReferencePropertyValueProvider = new JdbcBackReferencePropertyValueProvider(path, accessor); this.accessor = accessor; } diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategy.java index 960ec94e..95bc5138 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategy.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategy.java @@ -403,11 +403,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy { SqlIdentifier keyColumn = path.getQualifierColumn(); Assert.notNull(keyColumn, () -> "KeyColumn must not be null for " + path); - return new MapEntityRowMapper<>(path, converter, identifier, keyColumn, getIdentifierProcessing()); - } - - private IdentifierProcessing getIdentifierProcessing() { - return sqlGeneratorSource.getDialect().getIdentifierProcessing(); + return new MapEntityRowMapper<>(path, converter, identifier, keyColumn); } @SuppressWarnings("unchecked") diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcBackReferencePropertyValueProvider.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcBackReferencePropertyValueProvider.java index 3a42a6b3..65cdfc0e 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcBackReferencePropertyValueProvider.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcBackReferencePropertyValueProvider.java @@ -26,26 +26,22 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing; * * @author Jens Schauder * @author Kurt Niemi + * @author Mikhail Polivakha * @since 2.0 */ class JdbcBackReferencePropertyValueProvider implements PropertyValueProvider { - private final IdentifierProcessing identifierProcessing; private final PersistentPropertyPathExtension basePath; private final ResultSetAccessor resultSet; /** - * @param identifierProcessing used for converting the - * {@link org.springframework.data.relational.core.sql.SqlIdentifier} from a property to a column label * @param basePath path from the aggregate root relative to which all properties get resolved. * @param resultSet the {@link ResultSetAccessor} from which to obtain the actual values. */ - JdbcBackReferencePropertyValueProvider(IdentifierProcessing identifierProcessing, - PersistentPropertyPathExtension basePath, ResultSetAccessor resultSet) { + JdbcBackReferencePropertyValueProvider(PersistentPropertyPathExtension basePath, ResultSetAccessor resultSet) { this.resultSet = resultSet; this.basePath = basePath; - this.identifierProcessing = identifierProcessing; } @Override @@ -54,6 +50,6 @@ class JdbcBackReferencePropertyValueProvider implements PropertyValueProvider { - private final IdentifierProcessing identifierProcessing; private final PersistentPropertyPathExtension basePath; private final ResultSetAccessor resultSet; /** - * @param identifierProcessing used for converting the - * {@link org.springframework.data.relational.core.sql.SqlIdentifier} from a property to a column label * @param basePath path from the aggregate root relative to which all properties get resolved. * @param resultSet the {@link ResultSetAccessor} from which to obtain the actual values. */ - JdbcPropertyValueProvider(IdentifierProcessing identifierProcessing, PersistentPropertyPathExtension basePath, + JdbcPropertyValueProvider(PersistentPropertyPathExtension basePath, ResultSetAccessor resultSet) { this.resultSet = resultSet; this.basePath = basePath; - this.identifierProcessing = identifierProcessing; } @Override @@ -67,6 +63,6 @@ class JdbcPropertyValueProvider implements PropertyValueProvider implements RowMapper> { @@ -38,16 +39,12 @@ class MapEntityRowMapper implements RowMapper> { private final JdbcConverter converter; private final Identifier identifier; private final SqlIdentifier keyColumn; - private final IdentifierProcessing identifierProcessing; - - MapEntityRowMapper(PersistentPropertyPathExtension path, JdbcConverter converter, Identifier identifier, - SqlIdentifier keyColumn, IdentifierProcessing identifierProcessing) { + MapEntityRowMapper(PersistentPropertyPathExtension path, JdbcConverter converter, Identifier identifier, SqlIdentifier keyColumn) { this.path = path; this.converter = converter; this.identifier = identifier; this.keyColumn = keyColumn; - this.identifierProcessing = identifierProcessing; } @Override diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlIdentifierParameterSource.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlIdentifierParameterSource.java index f14f202e..3cd13c78 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlIdentifierParameterSource.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlIdentifierParameterSource.java @@ -21,7 +21,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.springframework.data.relational.core.sql.IdentifierProcessing; import org.springframework.data.relational.core.sql.SqlIdentifier; import org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource; @@ -31,16 +30,17 @@ import org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource; * * @author Jens Schauder * @author Kurt Niemi + * @author Mikhail Polivakha * @since 2.0 */ class SqlIdentifierParameterSource extends AbstractSqlParameterSource { - private final IdentifierProcessing identifierProcessing; - private final Set identifiers = new HashSet<>(); - private final Map namesToValues = new HashMap<>(); + private final Set identifiers; + private final Map namesToValues; - SqlIdentifierParameterSource(IdentifierProcessing identifierProcessing) { - this.identifierProcessing = identifierProcessing; + SqlIdentifierParameterSource() { + this.identifiers = new HashSet<>(); + this.namesToValues = new HashMap<>(); } @Override diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlParametersFactory.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlParametersFactory.java index d87e607f..04c3942c 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlParametersFactory.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlParametersFactory.java @@ -42,17 +42,21 @@ import org.springframework.util.Assert; * * @author Jens Schauder * @author Chirag Tailor + * @author Mikhail Polivakha * @since 2.4 */ public class SqlParametersFactory { private final RelationalMappingContext context; private final JdbcConverter converter; - private final Dialect dialect; + @Deprecated public SqlParametersFactory(RelationalMappingContext context, JdbcConverter converter, Dialect dialect) { + this(context, converter); + } + + public SqlParametersFactory(RelationalMappingContext context, JdbcConverter converter) { this.context = context; this.converter = converter; - this.dialect = dialect; } /** @@ -72,7 +76,7 @@ public class SqlParametersFactory { RelationalPersistentEntity persistentEntity = getRequiredPersistentEntity(domainType); SqlIdentifierParameterSource parameterSource = getParameterSource(instance, persistentEntity, "", - PersistentProperty::isIdProperty, dialect.getIdentifierProcessing()); + PersistentProperty::isIdProperty); identifier.forEach((name, value, type) -> addConvertedPropertyValue(parameterSource, name, value, type)); @@ -96,7 +100,7 @@ public class SqlParametersFactory { SqlIdentifierParameterSource forUpdate(T instance, Class domainType) { return getParameterSource(instance, getRequiredPersistentEntity(domainType), "", - RelationalPersistentProperty::isInsertOnly, dialect.getIdentifierProcessing()); + RelationalPersistentProperty::isInsertOnly); } /** @@ -110,7 +114,7 @@ public class SqlParametersFactory { */ SqlIdentifierParameterSource forQueryById(Object id, Class domainType, SqlIdentifier name) { - SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource(dialect.getIdentifierProcessing()); + SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource(); addConvertedPropertyValue( // parameterSource, // @@ -131,7 +135,7 @@ public class SqlParametersFactory { */ SqlIdentifierParameterSource forQueryByIds(Iterable ids, Class domainType) { - SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource(dialect.getIdentifierProcessing()); + SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource(); addConvertedPropertyValuesAsList(parameterSource, getRequiredPersistentEntity(domainType).getRequiredIdProperty(), ids); @@ -148,7 +152,7 @@ public class SqlParametersFactory { */ SqlIdentifierParameterSource forQueryByIdentifier(Identifier identifier) { - SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource(dialect.getIdentifierProcessing()); + SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource(); identifier.toMap() .forEach((name, value) -> addConvertedPropertyValue(parameterSource, name, value, value.getClass())); @@ -228,9 +232,9 @@ public class SqlParametersFactory { private SqlIdentifierParameterSource getParameterSource(@Nullable S instance, RelationalPersistentEntity persistentEntity, String prefix, - Predicate skipProperty, IdentifierProcessing identifierProcessing) { + Predicate skipProperty) { - SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(identifierProcessing); + SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(); PersistentPropertyAccessor propertyAccessor = instance != null ? persistentEntity.getPropertyAccessor(instance) : NoValuePropertyAccessor.instance(); @@ -249,8 +253,7 @@ public class SqlParametersFactory { Object value = propertyAccessor.getProperty(property); RelationalPersistentEntity embeddedEntity = context.getPersistentEntity(property.getType()); SqlIdentifierParameterSource additionalParameters = getParameterSource((T) value, - (RelationalPersistentEntity) embeddedEntity, prefix + property.getEmbeddedPrefix(), skipProperty, - identifierProcessing); + (RelationalPersistentEntity) embeddedEntity, prefix + property.getEmbeddedPrefix(), skipProperty); parameters.addAll(additionalParameters); } else { diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java index f6476518..288c517f 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/mybatis/MyBatisDataAccessStrategy.java @@ -60,6 +60,7 @@ import org.springframework.util.Assert; * @author Myeonghyeon Lee * @author Chirag Tailor * @author Christopher Klein + * @author Mikhail Polivakha */ public class MyBatisDataAccessStrategy implements DataAccessStrategy { @@ -88,7 +89,7 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy { SqlGeneratorSource sqlGeneratorSource = new SqlGeneratorSource(context, converter, dialect); - SqlParametersFactory sqlParametersFactory = new SqlParametersFactory(context, converter, dialect); + SqlParametersFactory sqlParametersFactory = new SqlParametersFactory(context, converter); InsertStrategyFactory insertStrategyFactory = new InsertStrategyFactory(operations, new BatchJdbcOperations(operations.getJdbcOperations()), dialect); DefaultDataAccessStrategy defaultDataAccessStrategy = new DefaultDataAccessStrategy( // @@ -125,11 +126,16 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy { * to create such a {@link DataAccessStrategy}. * * @param sqlSession Must be non {@literal null}. - * @param identifierProcessing the {@link IdentifierProcessing} applied to {@link SqlIdentifier} instances in order to - * turn them into {@link String} + * + * @deprecated because identifierProcessing now will not be considered in the process of applying it to {@link SqlIdentifier}, + * use {@link MyBatisDataAccessStrategy(SqlSession)} constructor instead */ + @Deprecated public MyBatisDataAccessStrategy(SqlSession sqlSession, IdentifierProcessing identifierProcessing) { + this(sqlSession); + } + public MyBatisDataAccessStrategy(SqlSession sqlSession) { this.sqlSession = sqlSession; } diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/AbstractJdbcConfiguration.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/AbstractJdbcConfiguration.java index 7293ddb9..ce920a59 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/AbstractJdbcConfiguration.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/AbstractJdbcConfiguration.java @@ -205,7 +205,7 @@ public class AbstractJdbcConfiguration implements ApplicationContextAware { public DataAccessStrategy dataAccessStrategyBean(NamedParameterJdbcOperations operations, JdbcConverter jdbcConverter, JdbcMappingContext context, Dialect dialect) { return new DefaultDataAccessStrategy(new SqlGeneratorSource(context, jdbcConverter, dialect), context, - jdbcConverter, operations, new SqlParametersFactory(context, jdbcConverter, dialect), + jdbcConverter, operations, new SqlParametersFactory(context, jdbcConverter), new InsertStrategyFactory(operations, new BatchJdbcOperations(operations.getJdbcOperations()), dialect)); } diff --git a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactoryBean.java b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactoryBean.java index 4e9cc2ed..f1bd6878 100644 --- a/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactoryBean.java +++ b/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcRepositoryFactoryBean.java @@ -181,8 +181,7 @@ public class JdbcRepositoryFactoryBean, S, ID extend SqlGeneratorSource sqlGeneratorSource = new SqlGeneratorSource(this.mappingContext, this.converter, this.dialect); - SqlParametersFactory sqlParametersFactory = new SqlParametersFactory(this.mappingContext, this.converter, - this.dialect); + SqlParametersFactory sqlParametersFactory = new SqlParametersFactory(this.mappingContext, this.converter); InsertStrategyFactory insertStrategyFactory = new InsertStrategyFactory(this.operations, new BatchJdbcOperations(this.operations.getJdbcOperations()), this.dialect); return new DefaultDataAccessStrategy(sqlGeneratorSource, this.mappingContext, this.converter, diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategyUnitTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategyUnitTests.java index 2324aa6b..5b968fe6 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategyUnitTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategyUnitTests.java @@ -74,7 +74,7 @@ class DefaultDataAccessStrategyUnitTests { relationResolver.setDelegate(accessStrategy); when(sqlParametersFactory.forInsert(any(), any(), any(), any())) - .thenReturn(new SqlIdentifierParameterSource(dialect.getIdentifierProcessing())); + .thenReturn(new SqlIdentifierParameterSource()); when(insertStrategyFactory.insertStrategy(any(), any())).thenReturn(mock(InsertStrategy.class)); when(insertStrategyFactory.batchInsertStrategy(any(), any())).thenReturn(mock(BatchInsertStrategy.class)); } diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/IdGeneratingBatchInsertStrategyTest.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/IdGeneratingBatchInsertStrategyTest.java index 0d72296b..ab0a5346 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/IdGeneratingBatchInsertStrategyTest.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/IdGeneratingBatchInsertStrategyTest.java @@ -44,8 +44,7 @@ class IdGeneratingBatchInsertStrategyTest { BatchJdbcOperations batchJdbcOperations = mock(BatchJdbcOperations.class); InsertStrategy insertStrategy = mock(InsertStrategy.class); String sql = "some sql"; - SqlParameterSource[] sqlParameterSources = new SqlParameterSource[] { - new SqlIdentifierParameterSource(identifierProcessing) }; + SqlParameterSource[] sqlParameterSources = new SqlParameterSource[] {new SqlIdentifierParameterSource() }; @Test void insertsSequentially_whenIdGenerationForBatchOperationsNotSupported() { @@ -53,9 +52,9 @@ class IdGeneratingBatchInsertStrategyTest { BatchInsertStrategy batchInsertStrategy = new IdGeneratingBatchInsertStrategy(insertStrategy, createDialect(identifierProcessing, true, false), batchJdbcOperations, idColumn); - SqlIdentifierParameterSource sqlParameterSource1 = new SqlIdentifierParameterSource(identifierProcessing); + SqlIdentifierParameterSource sqlParameterSource1 = new SqlIdentifierParameterSource(); sqlParameterSource1.addValue(SqlIdentifier.quoted("property1"), "value1"); - SqlIdentifierParameterSource sqlParameterSource2 = new SqlIdentifierParameterSource(identifierProcessing); + SqlIdentifierParameterSource sqlParameterSource2 = new SqlIdentifierParameterSource(); sqlParameterSource2.addValue(SqlIdentifier.quoted("property2"), "value2"); long id1 = 1L; diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/IdGeneratingInsertStrategyTest.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/IdGeneratingInsertStrategyTest.java index 22377473..a7e0aad5 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/IdGeneratingInsertStrategyTest.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/IdGeneratingInsertStrategyTest.java @@ -44,7 +44,7 @@ class IdGeneratingInsertStrategyTest { IdentifierProcessing identifierProcessing = IdentifierProcessing.ANSI; NamedParameterJdbcOperations namedParameterJdbcOperations = mock(NamedParameterJdbcOperations.class); String sql = "some sql"; - SqlParameterSource sqlParameterSource = new SqlIdentifierParameterSource(identifierProcessing); + SqlParameterSource sqlParameterSource = new SqlIdentifierParameterSource(); @Test void insertsWithKeyHolderAndKeyColumnNames_whenDriverRequiresKeyColumnNames() { diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/InsertStrategyFactoryTest.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/InsertStrategyFactoryTest.java index 28717d56..50e23918 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/InsertStrategyFactoryTest.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/InsertStrategyFactoryTest.java @@ -32,15 +32,13 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource; */ class InsertStrategyFactoryTest { - IdentifierProcessing identifierProcessing = IdentifierProcessing.ANSI; - NamedParameterJdbcOperations namedParameterJdbcOperations = mock(NamedParameterJdbcOperations.class); BatchJdbcOperations batchJdbcOperations = mock(BatchJdbcOperations.class); InsertStrategyFactory insertStrategyFactory = new InsertStrategyFactory(namedParameterJdbcOperations, batchJdbcOperations, AnsiDialect.INSTANCE); String sql = "some sql"; - SqlParameterSource sqlParameterSource = new SqlIdentifierParameterSource(identifierProcessing); + SqlParameterSource sqlParameterSource = new SqlIdentifierParameterSource(); SqlParameterSource[] sqlParameterSources = new SqlParameterSource[] { sqlParameterSource }; @Test diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/SqlIdentifierParameterSourceUnitTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/SqlIdentifierParameterSourceUnitTests.java index 563df097..01277fc3 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/SqlIdentifierParameterSourceUnitTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/SqlIdentifierParameterSourceUnitTests.java @@ -27,15 +27,14 @@ import java.util.Arrays; * Tests for {@link SqlIdentifierParameterSource}. * * @author Jens Schauder + * @author Mikhail Polivakha */ public class SqlIdentifierParameterSourceUnitTests { - private IdentifierProcessing identifierProcessing = IdentifierProcessing.ANSI; - @Test // DATAJDBC-386 public void empty() { - SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(identifierProcessing); + SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(); assertSoftly(softly -> { @@ -49,7 +48,7 @@ public class SqlIdentifierParameterSourceUnitTests { @Test // DATAJDBC-386 public void addSingleValue() { - SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(identifierProcessing); + SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(); parameters.addValue(SqlIdentifier.unquoted("key"), 23); @@ -68,7 +67,7 @@ public class SqlIdentifierParameterSourceUnitTests { @Test // DATAJDBC-386 public void addSingleValueWithType() { - SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(identifierProcessing); + SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(); parameters.addValue(SqlIdentifier.unquoted("key"), 23, 42); @@ -88,11 +87,11 @@ public class SqlIdentifierParameterSourceUnitTests { @Test // DATAJDBC-386 public void addOtherDatabaseObjectIdentifierParameterSource() { - SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(identifierProcessing); + SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(); parameters.addValue(SqlIdentifier.unquoted("key1"), 111, 11); parameters.addValue(SqlIdentifier.unquoted("key2"), 111); - SqlIdentifierParameterSource parameters2 = new SqlIdentifierParameterSource(identifierProcessing); + SqlIdentifierParameterSource parameters2 = new SqlIdentifierParameterSource(); parameters2.addValue(SqlIdentifier.unquoted("key2"), 222, 22); parameters2.addValue(SqlIdentifier.unquoted("key3"), 222); diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/SqlParametersFactoryTest.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/SqlParametersFactoryTest.java index 25d37ca9..35f96bc3 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/SqlParametersFactoryTest.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/SqlParametersFactoryTest.java @@ -54,7 +54,7 @@ class SqlParametersFactoryTest { RelationResolver relationResolver = mock(RelationResolver.class); BasicJdbcConverter converter = new BasicJdbcConverter(context, relationResolver); AnsiDialect dialect = AnsiDialect.INSTANCE; - SqlParametersFactory sqlParametersFactory = new SqlParametersFactory(context, converter, dialect); + SqlParametersFactory sqlParametersFactory = new SqlParametersFactory(context, converter); @Test // DATAJDBC-412 public void considersConfiguredWriteConverterForIdValueObjects_onRead() { @@ -243,6 +243,6 @@ class SqlParametersFactoryTest { BasicJdbcConverter converter = new BasicJdbcConverter(context, relationResolver, new JdbcCustomConversions(converters), new DefaultJdbcTypeFactory(mock(JdbcOperations.class)), dialect.getIdentifierProcessing()); - return new SqlParametersFactory(context, converter, dialect); + return new SqlParametersFactory(context, converter); } } diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/SimpleJdbcRepositoryEventsUnitTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/SimpleJdbcRepositoryEventsUnitTests.java index 95b355e2..e9f494d4 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/SimpleJdbcRepositoryEventsUnitTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/SimpleJdbcRepositoryEventsUnitTests.java @@ -103,7 +103,7 @@ class SimpleJdbcRepositoryEventsUnitTests { JdbcConverter converter = new BasicJdbcConverter(context, delegatingDataAccessStrategy, new JdbcCustomConversions(), new DefaultJdbcTypeFactory(operations.getJdbcOperations()), dialect.getIdentifierProcessing()); SqlGeneratorSource generatorSource = new SqlGeneratorSource(context, converter, dialect); - SqlParametersFactory sqlParametersFactory = new SqlParametersFactory(context, converter, dialect); + SqlParametersFactory sqlParametersFactory = new SqlParametersFactory(context, converter); InsertStrategyFactory insertStrategyFactory = new InsertStrategyFactory(operations, new BatchJdbcOperations(operations.getJdbcOperations()), dialect); diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java index 6302785d..c5c60f7e 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/config/EnableJdbcRepositoriesIntegrationTests.java @@ -164,7 +164,7 @@ public class EnableJdbcRepositoriesIntegrationTests { @Qualifier("namedParameterJdbcTemplate") NamedParameterJdbcOperations template, RelationalMappingContext context, JdbcConverter converter, Dialect dialect) { return new DefaultDataAccessStrategy(new SqlGeneratorSource(context, converter, dialect), context, converter, - template, new SqlParametersFactory(context, converter, dialect), + template, new SqlParametersFactory(context, converter), new InsertStrategyFactory(template, new BatchJdbcOperations(template.getJdbcOperations()), dialect)); } diff --git a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/TestConfiguration.java b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/TestConfiguration.java index a02e081d..e4c77ac4 100644 --- a/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/TestConfiguration.java +++ b/spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/TestConfiguration.java @@ -108,7 +108,7 @@ public class TestConfiguration { RelationalMappingContext context, JdbcConverter converter, Dialect dialect) { return new DefaultDataAccessStrategy(new SqlGeneratorSource(context, converter, dialect), context, converter, - template, new SqlParametersFactory(context, converter, dialect), + template, new SqlParametersFactory(context, converter), new InsertStrategyFactory(template, new BatchJdbcOperations(template.getJdbcOperations()), dialect)); }