Skip to content

Commit 382a423

Browse files
committed
1 parent 0500442 commit 382a423

32 files changed

+89
-111
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,8 @@ private ReadingContext(PersistentPropertyPathExtension rootPath, ResultSetAccess
388388
this.path = new PersistentPropertyPathExtension(getMappingContext(), this.entity);
389389
this.identifier = identifier;
390390
this.key = key;
391-
this.propertyValueProvider = new JdbcPropertyValueProvider(identifierProcessing, path, accessor);
392-
this.backReferencePropertyValueProvider = new JdbcBackReferencePropertyValueProvider(identifierProcessing, path,
393-
accessor);
391+
this.propertyValueProvider = new JdbcPropertyValueProvider(path, accessor);
392+
this.backReferencePropertyValueProvider = new JdbcBackReferencePropertyValueProvider(path, accessor);
394393
this.accessor = accessor;
395394
}
396395

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,7 @@ private RowMapper<?> getMapEntityRowMapper(PersistentPropertyPathExtension path,
327327
SqlIdentifier keyColumn = path.getQualifierColumn();
328328
Assert.notNull(keyColumn, () -> "KeyColumn must not be null for " + path);
329329

330-
return new MapEntityRowMapper<>(path, converter, identifier, keyColumn, getIdentifierProcessing());
331-
}
332-
333-
private IdentifierProcessing getIdentifierProcessing() {
334-
return sqlGeneratorSource.getDialect().getIdentifierProcessing();
330+
return new MapEntityRowMapper<>(path, converter, identifier, keyColumn);
335331
}
336332

337333
@SuppressWarnings("unchecked")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public Object[] execute(String sql, SqlParameterSource[] sqlParameterSources) {
7979
Map<String, Object> keys = keyList.get(i);
8080
if (keys.size() > 1) {
8181
if (idColumn != null) {
82-
ids[i] = keys.get(idColumn.getReference(dialect.getIdentifierProcessing()));
82+
ids[i] = keys.get(idColumn.getReference());
8383
}
8484
} else {
8585
ids[i] = keys.entrySet().stream().findFirst() //
@@ -93,7 +93,7 @@ public Object[] execute(String sql, SqlParameterSource[] sqlParameterSources) {
9393
private String[] getKeyColumnNames() {
9494

9595
return Optional.ofNullable(idColumn)
96-
.map(idColumn -> new String[] { idColumn.getReference(dialect.getIdentifierProcessing()) })
96+
.map(idColumn -> new String[] { idColumn.getReference() })
9797
.orElse(new String[0]);
9898
}
9999
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ public Object execute(String sql, SqlParameterSource sqlParameterSource) {
7979
return null;
8080
}
8181

82-
return keys.get(idColumn.getReference(dialect.getIdentifierProcessing()));
82+
return keys.get(idColumn.getReference());
8383
}
8484
}
8585

8686
private String[] getKeyColumnNames() {
8787
return Optional.ofNullable(idColumn)
88-
.map(idColumn -> new String[] { idColumn.getReference(dialect.getIdentifierProcessing()) })
88+
.map(idColumn -> new String[] { idColumn.getReference() })
8989
.orElse(new String[0]);
9090
}
9191
}

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,30 @@
2525
* the value in the resultset under which other entities refer back to it.
2626
*
2727
* @author Jens Schauder
28+
* @author Mikhail Polivakha
2829
* @since 2.0
2930
*/
3031
class JdbcBackReferencePropertyValueProvider implements PropertyValueProvider<RelationalPersistentProperty> {
3132

32-
private final IdentifierProcessing identifierProcessing;
3333
private final PersistentPropertyPathExtension basePath;
3434
private final ResultSetAccessor resultSet;
3535

3636
/**
37-
* @param identifierProcessing used for converting the
38-
* {@link org.springframework.data.relational.core.sql.SqlIdentifier} from a property to a column label
3937
* @param basePath path from the aggregate root relative to which all properties get resolved.
4038
* @param resultSet the {@link ResultSetAccessor} from which to obtain the actual values.
4139
*/
42-
JdbcBackReferencePropertyValueProvider(IdentifierProcessing identifierProcessing,
43-
PersistentPropertyPathExtension basePath, ResultSetAccessor resultSet) {
40+
JdbcBackReferencePropertyValueProvider(PersistentPropertyPathExtension basePath, ResultSetAccessor resultSet) {
4441

4542
this.resultSet = resultSet;
4643
this.basePath = basePath;
47-
this.identifierProcessing = identifierProcessing;
4844
}
4945

5046
@Override
5147
public <T> T getPropertyValue(RelationalPersistentProperty property) {
52-
return (T) resultSet
53-
.getObject(basePath.extendBy(property).getReverseColumnNameAlias().getReference(identifierProcessing));
48+
return (T) resultSet.getObject(basePath.extendBy(property).getReverseColumnNameAlias().getReference());
5449
}
5550

5651
public JdbcBackReferencePropertyValueProvider extendBy(RelationalPersistentProperty property) {
57-
return new JdbcBackReferencePropertyValueProvider(identifierProcessing, basePath.extendBy(property), resultSet);
52+
return new JdbcBackReferencePropertyValueProvider(basePath.extendBy(property), resultSet);
5853
}
5954
}

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,18 @@
2828
*/
2929
class JdbcPropertyValueProvider implements PropertyValueProvider<RelationalPersistentProperty> {
3030

31-
private final IdentifierProcessing identifierProcessing;
3231
private final PersistentPropertyPathExtension basePath;
3332
private final ResultSetAccessor resultSet;
3433

3534
/**
36-
* @param identifierProcessing used for converting the
37-
* {@link org.springframework.data.relational.core.sql.SqlIdentifier} from a property to a column label
3835
* @param basePath path from the aggregate root relative to which all properties get resolved.
3936
* @param resultSet the {@link ResultSetAccessor} from which to obtain the actual values.
4037
*/
41-
JdbcPropertyValueProvider(IdentifierProcessing identifierProcessing, PersistentPropertyPathExtension basePath,
38+
JdbcPropertyValueProvider(PersistentPropertyPathExtension basePath,
4239
ResultSetAccessor resultSet) {
4340

4441
this.resultSet = resultSet;
4542
this.basePath = basePath;
46-
this.identifierProcessing = identifierProcessing;
4743
}
4844

4945
@Override
@@ -62,10 +58,10 @@ public boolean hasProperty(RelationalPersistentProperty property) {
6258
}
6359

6460
private String getColumnName(RelationalPersistentProperty property) {
65-
return basePath.extendBy(property).getColumnAlias().getReference(identifierProcessing);
61+
return basePath.extendBy(property).getColumnAlias().getReference();
6662
}
6763

6864
public JdbcPropertyValueProvider extendBy(RelationalPersistentProperty property) {
69-
return new JdbcPropertyValueProvider(identifierProcessing, basePath.extendBy(property), resultSet);
65+
return new JdbcPropertyValueProvider(basePath.extendBy(property), resultSet);
7066
}
7167
}

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,26 @@
3131
* {@link Map.Entry} is delegated to a {@link RowMapper} provided in the constructor.
3232
*
3333
* @author Jens Schauder
34+
* @author Mikhail Polivakha
3435
*/
3536
class MapEntityRowMapper<T> implements RowMapper<Map.Entry<Object, T>> {
3637

3738
private final PersistentPropertyPathExtension path;
3839
private final JdbcConverter converter;
3940
private final Identifier identifier;
4041
private final SqlIdentifier keyColumn;
41-
private final IdentifierProcessing identifierProcessing;
42-
43-
MapEntityRowMapper(PersistentPropertyPathExtension path, JdbcConverter converter, Identifier identifier,
44-
SqlIdentifier keyColumn, IdentifierProcessing identifierProcessing) {
4542

43+
MapEntityRowMapper(PersistentPropertyPathExtension path, JdbcConverter converter, Identifier identifier, SqlIdentifier keyColumn) {
4644
this.path = path;
4745
this.converter = converter;
4846
this.identifier = identifier;
4947
this.keyColumn = keyColumn;
50-
this.identifierProcessing = identifierProcessing;
5148
}
5249

5350
@Override
5451
public Map.Entry<Object, T> mapRow(ResultSet rs, int rowNum) throws SQLException {
5552

56-
Object key = rs.getObject(keyColumn.getReference(identifierProcessing));
53+
Object key = rs.getObject(keyColumn.getReference());
5754
return new HashMap.SimpleEntry<>(key, mapEntity(rs, key));
5855
}
5956

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ private Column getVersionColumn() {
705705
}
706706

707707
private String renderReference(SqlIdentifier identifier) {
708-
return identifier.getReference(renderContext.getIdentifierProcessing());
708+
return identifier.getReference();
709709
}
710710

711711
private List<OrderByField> extractOrderByFields(Sort sort) {

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@
3030
* {@link SqlIdentifier} instead of {@link String} for names.
3131
*
3232
* @author Jens Schauder
33+
* @author Mikhail Polivakha
3334
* @since 2.0
3435
*/
3536
class SqlIdentifierParameterSource extends AbstractSqlParameterSource {
3637

37-
private final IdentifierProcessing identifierProcessing;
38-
private final Set<SqlIdentifier> identifiers = new HashSet<>();
39-
private final Map<String, Object> namesToValues = new HashMap<>();
38+
private final Set<SqlIdentifier> identifiers;
39+
private final Map<String, Object> namesToValues;
4040

41-
SqlIdentifierParameterSource(IdentifierProcessing identifierProcessing) {
42-
this.identifierProcessing = identifierProcessing;
41+
SqlIdentifierParameterSource() {
42+
this.identifiers = new HashSet<>();
43+
this.namesToValues = new HashMap<>();
4344
}
4445

4546
@Override
@@ -68,7 +69,7 @@ void addValue(SqlIdentifier name, Object value) {
6869
void addValue(SqlIdentifier identifier, Object value, int sqlType) {
6970

7071
identifiers.add(identifier);
71-
String name = identifier.getReference(identifierProcessing);
72+
String name = identifier.getReference();
7273
namesToValues.put(name, value);
7374
registerSqlType(name, sqlType);
7475
}
@@ -77,7 +78,7 @@ void addAll(SqlIdentifierParameterSource others) {
7778

7879
for (SqlIdentifier identifier : others.getIdentifiers()) {
7980

80-
String name = identifier.getReference(identifierProcessing);
81+
String name = identifier.getReference();
8182
addValue(identifier, others.getValue(name), others.getSqlType(name));
8283
}
8384
}

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,21 @@
4242
*
4343
* @author Jens Schauder
4444
* @author Chirag Tailor
45+
* @author Mikhail Polivakha
4546
* @since 2.4
4647
*/
4748
public class SqlParametersFactory {
4849
private final RelationalMappingContext context;
4950
private final JdbcConverter converter;
50-
private final Dialect dialect;
5151

52+
@Deprecated
5253
public SqlParametersFactory(RelationalMappingContext context, JdbcConverter converter, Dialect dialect) {
54+
this(context, converter);
55+
}
56+
57+
public SqlParametersFactory(RelationalMappingContext context, JdbcConverter converter) {
5358
this.context = context;
5459
this.converter = converter;
55-
this.dialect = dialect;
5660
}
5761

5862
/**
@@ -72,7 +76,7 @@ <T> SqlIdentifierParameterSource forInsert(T instance, Class<T> domainType, Iden
7276

7377
RelationalPersistentEntity<T> persistentEntity = getRequiredPersistentEntity(domainType);
7478
SqlIdentifierParameterSource parameterSource = getParameterSource(instance, persistentEntity, "",
75-
PersistentProperty::isIdProperty, dialect.getIdentifierProcessing());
79+
PersistentProperty::isIdProperty);
7680

7781
identifier.forEach((name, value, type) -> addConvertedPropertyValue(parameterSource, name, value, type));
7882

@@ -95,8 +99,7 @@ <T> SqlIdentifierParameterSource forInsert(T instance, Class<T> domainType, Iden
9599
*/
96100
<T> SqlIdentifierParameterSource forUpdate(T instance, Class<T> domainType) {
97101

98-
return getParameterSource(instance, getRequiredPersistentEntity(domainType), "", Predicates.includeAll(),
99-
dialect.getIdentifierProcessing());
102+
return getParameterSource(instance, getRequiredPersistentEntity(domainType), "", Predicates.includeAll());
100103
}
101104

102105
/**
@@ -110,7 +113,7 @@ <T> SqlIdentifierParameterSource forUpdate(T instance, Class<T> domainType) {
110113
*/
111114
<T> SqlIdentifierParameterSource forQueryById(Object id, Class<T> domainType, SqlIdentifier name) {
112115

113-
SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource(dialect.getIdentifierProcessing());
116+
SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource();
114117

115118
addConvertedPropertyValue( //
116119
parameterSource, //
@@ -131,7 +134,7 @@ <T> SqlIdentifierParameterSource forQueryById(Object id, Class<T> domainType, Sq
131134
*/
132135
<T> SqlIdentifierParameterSource forQueryByIds(Iterable<?> ids, Class<T> domainType) {
133136

134-
SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource(dialect.getIdentifierProcessing());
137+
SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource();
135138

136139
addConvertedPropertyValuesAsList(parameterSource, getRequiredPersistentEntity(domainType).getRequiredIdProperty(),
137140
ids);
@@ -148,7 +151,7 @@ <T> SqlIdentifierParameterSource forQueryByIds(Iterable<?> ids, Class<T> domainT
148151
*/
149152
SqlIdentifierParameterSource forQueryByIdentifier(Identifier identifier) {
150153

151-
SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource(dialect.getIdentifierProcessing());
154+
SqlIdentifierParameterSource parameterSource = new SqlIdentifierParameterSource();
152155

153156
identifier.toMap()
154157
.forEach((name, value) -> addConvertedPropertyValue(parameterSource, name, value, value.getClass()));
@@ -228,9 +231,9 @@ private <S> RelationalPersistentEntity<S> getRequiredPersistentEntity(Class<S> d
228231

229232
private <S, T> SqlIdentifierParameterSource getParameterSource(@Nullable S instance,
230233
RelationalPersistentEntity<S> persistentEntity, String prefix,
231-
Predicate<RelationalPersistentProperty> skipProperty, IdentifierProcessing identifierProcessing) {
234+
Predicate<RelationalPersistentProperty> skipProperty) {
232235

233-
SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource(identifierProcessing);
236+
SqlIdentifierParameterSource parameters = new SqlIdentifierParameterSource();
234237

235238
PersistentPropertyAccessor<S> propertyAccessor = instance != null ? persistentEntity.getPropertyAccessor(instance)
236239
: NoValuePropertyAccessor.instance();
@@ -249,8 +252,7 @@ private <S, T> SqlIdentifierParameterSource getParameterSource(@Nullable S insta
249252
Object value = propertyAccessor.getProperty(property);
250253
RelationalPersistentEntity<?> embeddedEntity = context.getPersistentEntity(property.getType());
251254
SqlIdentifierParameterSource additionalParameters = getParameterSource((T) value,
252-
(RelationalPersistentEntity<T>) embeddedEntity, prefix + property.getEmbeddedPrefix(), skipProperty,
253-
identifierProcessing);
255+
(RelationalPersistentEntity<T>) embeddedEntity, prefix + property.getEmbeddedPrefix(), skipProperty);
254256
parameters.addAll(additionalParameters);
255257
} else {
256258

0 commit comments

Comments
 (0)