Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-1110-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data Relational Parent</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-data-jdbc-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-1110-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions spring-data-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-data-jdbc</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-1110-SNAPSHOT</version>

<name>Spring Data JDBC</name>
<description>Spring Data module for JDBC repositories.</description>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-1110-SNAPSHOT</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public Object[] execute(String sql, SqlParameterSource[] sqlParameterSources) {
Map<String, Object> keys = keyList.get(i);
if (keys.size() > 1) {
if (idColumn != null) {
ids[i] = keys.get(idColumn.getReference(dialect.getIdentifierProcessing()));
ids[i] = keys.get(idColumn.getReference());
}
} else {
ids[i] = keys.entrySet().stream().findFirst() //
Expand All @@ -93,7 +93,7 @@ public Object[] execute(String sql, SqlParameterSource[] sqlParameterSources) {
private String[] getKeyColumnNames() {

return Optional.ofNullable(idColumn)
.map(idColumn -> new String[] { idColumn.getReference(dialect.getIdentifierProcessing()) })
.map(idColumn -> new String[] { idColumn.getReference() })
.orElse(new String[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ public Object execute(String sql, SqlParameterSource sqlParameterSource) {
return null;
}

return keys.get(idColumn.getReference(dialect.getIdentifierProcessing()));
return keys.get(idColumn.getReference());
}
}

private String[] getKeyColumnNames() {
return Optional.ofNullable(idColumn)
.map(idColumn -> new String[] { idColumn.getReference(dialect.getIdentifierProcessing()) })
.map(idColumn -> new String[] { idColumn.getReference() })
.orElse(new String[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class JdbcBackReferencePropertyValueProvider implements PropertyValueProvider<Re
@Override
public <T> T getPropertyValue(RelationalPersistentProperty property) {
return (T) resultSet
.getObject(basePath.extendBy(property).getReverseColumnNameAlias().getReference(identifierProcessing));
.getObject(basePath.extendBy(property).getReverseColumnNameAlias().getReference());
}

public JdbcBackReferencePropertyValueProvider extendBy(RelationalPersistentProperty property) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public boolean hasProperty(RelationalPersistentProperty property) {
}

private String getColumnName(RelationalPersistentProperty property) {
return basePath.extendBy(property).getColumnAlias().getReference(identifierProcessing);
return basePath.extendBy(property).getColumnAlias().getReference();
}

public JdbcPropertyValueProvider extendBy(RelationalPersistentProperty property) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MapEntityRowMapper<T> implements RowMapper<Map.Entry<Object, T>> {
@Override
public Map.Entry<Object, T> mapRow(ResultSet rs, int rowNum) throws SQLException {

Object key = rs.getObject(keyColumn.getReference(identifierProcessing));
Object key = rs.getObject(keyColumn.getReference());
return new HashMap.SimpleEntry<>(key, mapEntity(rs, key));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ private Column getVersionColumn() {
}

private String renderReference(SqlIdentifier identifier) {
return identifier.getReference(renderContext.getIdentifierProcessing());
return identifier.getReference();
}

private List<OrderByField> extractOrderByFields(Sort sort) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void addValue(SqlIdentifier name, Object value) {
void addValue(SqlIdentifier identifier, Object value, int sqlType) {

identifiers.add(identifier);
String name = BindParameterNameSanitizer.sanitize(identifier.getReference(identifierProcessing));
String name = BindParameterNameSanitizer.sanitize(identifier.getReference());
namesToValues.put(name, value);
registerSqlType(name, sqlType);
}
Expand All @@ -77,7 +77,7 @@ void addAll(SqlIdentifierParameterSource others) {

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

String name = identifier.getReference(identifierProcessing);
String name = identifier.getReference();
addValue(identifier, others.getValue(name), others.getSqlType(name));
}
}
Expand Down
4 changes: 2 additions & 2 deletions spring-data-r2dbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-data-r2dbc</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-1110-SNAPSHOT</version>

<name>Spring Data R2DBC</name>
<description>Spring Data module for R2DBC</description>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-1110-SNAPSHOT</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public BindMarkersFactory getBindMarkersFactory() {

@Override
public String renderForGeneratedValues(SqlIdentifier identifier) {
return identifier.getReference(getIdentifierProcessing());
return identifier.getReference();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Boolean convert(Byte s) {

@Override
public String renderForGeneratedValues(SqlIdentifier identifier) {
return identifier.getReference(getIdentifierProcessing());
return identifier.getReference();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions spring-data-relational/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-data-relational</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-1110-SNAPSHOT</version>

<name>Spring Data Relational</name>
<description>Spring Data Relational support</description>

<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>3.1.0-SNAPSHOT</version>
<version>3.1.0-1110-SNAPSHOT</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public String toSql(IdentifierProcessing processing) {
}

@Override
@Deprecated(since="3.1", forRemoval = true)
public String getReference(IdentifierProcessing processing) {
return this.name;
return toSql(processing);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ default String getReverseColumnName(RelationalPersistentProperty property) {

Assert.notNull(property, "Property must not be null");

return property.getOwner().getTableName().getReference(IdentifierProcessing.NONE);
return property.getOwner().getTableName().getReference();
}

default String getReverseColumnName(PersistentPropertyPathExtension path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ private SqlIdentifier prefixWithTableAlias(SqlIdentifier columnName) {

SqlIdentifier tableAlias = getTableAlias();
return tableAlias == null ? columnName
: columnName.transform(name -> tableAlias.getReference(IdentifierProcessing.NONE) + "_" + name);
: columnName.transform(name -> tableAlias.getReference() + "_" + name);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public String toSql(IdentifierProcessing processing) {
}

@Override
@Deprecated(since="3.1", forRemoval = true)
public String getReference(IdentifierProcessing processing) {
throw new UnsupportedOperationException("Composite SQL Identifiers can't be used for reference name retrieval");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ public SqlIdentifier transform(UnaryOperator<String> transformationFunction) {

@Override
public String toSql(IdentifierProcessing processing) {
return quoted ? processing.quote(getReference(processing)) : getReference(processing);
return quoted ? processing.quote(name) : name;
}

@Override
@Deprecated(since="3.1", forRemoval = true)
public String getReference(IdentifierProcessing processing) {
return name;
return toSql(processing);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* from a {@link String name} with specifying whether the name should be quoted or unquoted.
* <p>
* {@link SqlIdentifier} renders its name using {@link IdentifierProcessing} rules. Use
* {@link #getReference(IdentifierProcessing)} to refer to an object using the identifier when e.g. obtaining values
* {@link #getReference()} to refer to an object using the identifier when e.g. obtaining values
* from a result or providing values for a prepared statement. {@link #toSql(IdentifierProcessing)} renders the
* identifier for SQL statement usage.
* <p>
Expand All @@ -39,6 +39,7 @@
*
* @author Jens Schauder
* @author Mark Paluch
* @author Kurt Niemi
* @since 2.0
*/
public interface SqlIdentifier extends Streamable<SqlIdentifier> {
Expand Down Expand Up @@ -79,23 +80,26 @@ public String toString() {
*
* @param processing identifier processing rules.
* @return
* @deprecated since 3.1, use the #getReference() method instead.
*/
@Deprecated(since="3.1", forRemoval = true)
String getReference(IdentifierProcessing processing);

/**
* Return the reference name without any further transformation. The reference name is used for programmatic access to
* the object identified by this {@link SqlIdentifier}.
* Use this method whenever accessing a column in a ResultSet and we do not want any quoting applied. The
* reference name is used for programmatic access to the object identified by this {@link SqlIdentifier}.
*
* @return
* @see IdentifierProcessing#NONE
*/
default String getReference() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give this a proper JavaDoc comment.

After talking to Mark I now again understand what the getReference vs toSql is about.

toSql is to be used when rendering an identifier in SQL, as in select id from someTable

getReference is used when accessing a column in a ResultSet here we must not apply any quoting.

This should be reflected in the JavaDoc comments of the two methods.

return getReference(IdentifierProcessing.NONE);
return toSql(IdentifierProcessing.NONE);
}

/**
* Return the identifier for SQL usage after applying {@link IdentifierProcessing} rules. The identifier name is used
* to construct SQL statements.
* Use this method when rendering an identifier in SQL statements as in:
* <pre><code>select yourColumn from someTable</code></pre>
* {@link IdentifierProcessing} rules are applied to the identifier.
*
* @param processing identifier processing rules.
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void quotedSimpleObjectIdentifierWithAdjustableLetterCasing() {
SqlIdentifier identifier = new DerivedSqlIdentifier("someName", true);

assertThat(identifier.toSql(BRACKETS_LOWER_CASE)).isEqualTo("[somename]");
assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("someName");
assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("[somename]");
assertThat(identifier.getReference()).isEqualTo("someName");

}

Expand All @@ -52,7 +53,8 @@ public void unquotedSimpleObjectIdentifierWithAdjustableLetterCasing() {
String sql = identifier.toSql(BRACKETS_LOWER_CASE);

assertThat(sql).isEqualTo("somename");
assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("someName");
assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("somename");
assertThat(identifier.getReference()).isEqualTo("someName");
}

@Test // DATAJDBC-386
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public void quotedSimpleObjectIdentifier() {
SqlIdentifier identifier = quoted("someName");

assertThat(identifier.toSql(BRACKETS_LOWER_CASE)).isEqualTo("[someName]");
assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("someName");
assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("[someName]");
assertThat(identifier.getReference()).isEqualTo("someName");
}

@Test // DATAJDBC-386
Expand All @@ -51,6 +52,7 @@ public void unquotedSimpleObjectIdentifier() {

assertThat(sql).isEqualTo("someName");
assertThat(identifier.getReference(BRACKETS_LOWER_CASE)).isEqualTo("someName");
assertThat(identifier.getReference()).isEqualTo("someName");
}

@Test // DATAJDBC-386
Expand Down