Browse Source

Polishing.

Added `@author` tags.
Undo the change in behaviour of getReference(IdentifierProcessing).

See #1110
Original pull request #1458
pull/1489/head
Jens Schauder 3 years ago
parent
commit
58a67ceb2a
No known key found for this signature in database
GPG Key ID: 9537B67540F0A581
  1. 1
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IdGeneratingBatchInsertStrategy.java
  2. 4
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/IdGeneratingInsertStrategy.java
  3. 4
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcBackReferencePropertyValueProvider.java
  4. 1
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/JdbcPropertyValueProvider.java
  5. 1
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlGenerator.java
  6. 1
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/SqlIdentifierParameterSource.java
  7. 1
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/H2Dialect.java
  8. 1
      spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/MySqlDialect.java
  9. 3
      spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/DerivedSqlIdentifier.java
  10. 1
      spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/NamingStrategy.java
  11. 1
      spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/PersistentPropertyPathExtension.java
  12. 3
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/DefaultSqlIdentifier.java
  13. 21
      spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/SqlIdentifier.java
  14. 5
      spring-data-relational/src/test/java/org/springframework/data/relational/core/mapping/DerivedSqlIdentifierUnitTests.java
  15. 3
      spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/SqlIdentifierUnitTests.java

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

@ -32,6 +32,7 @@ import org.springframework.lang.Nullable; @@ -32,6 +32,7 @@ import org.springframework.lang.Nullable;
* not support id generation for batch operations, this implementation falls back to performing the inserts serially.
*
* @author Chirag Tailor
* @author Kurt Niemi
* @since 2.4
*/
class IdGeneratingBatchInsertStrategy implements BatchInsertStrategy {

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

@ -33,6 +33,7 @@ import org.springframework.lang.Nullable; @@ -33,6 +33,7 @@ import org.springframework.lang.Nullable;
* An {@link InsertStrategy} that expects an id to be generated from the insert.
*
* @author Chirag Tailor
* @author Kurt Niemi
* @since 2.4
*/
class IdGeneratingInsertStrategy implements InsertStrategy {
@ -84,8 +85,7 @@ class IdGeneratingInsertStrategy implements InsertStrategy { @@ -84,8 +85,7 @@ class IdGeneratingInsertStrategy implements InsertStrategy {
}
private String[] getKeyColumnNames() {
return Optional.ofNullable(idColumn)
.map(idColumn -> new String[] { idColumn.getReference() })
return Optional.ofNullable(idColumn).map(idColumn -> new String[] { idColumn.getReference() })
.orElse(new String[0]);
}
}

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

@ -25,6 +25,7 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing; @@ -25,6 +25,7 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing;
* the value in the resultset under which other entities refer back to it.
*
* @author Jens Schauder
* @author Kurt Niemi
* @since 2.0
*/
class JdbcBackReferencePropertyValueProvider implements PropertyValueProvider<RelationalPersistentProperty> {
@ -49,8 +50,7 @@ class JdbcBackReferencePropertyValueProvider implements PropertyValueProvider<Re @@ -49,8 +50,7 @@ class JdbcBackReferencePropertyValueProvider implements PropertyValueProvider<Re
@Override
public <T> T getPropertyValue(RelationalPersistentProperty property) {
return (T) resultSet
.getObject(basePath.extendBy(property).getReverseColumnNameAlias().getReference());
return (T) resultSet.getObject(basePath.extendBy(property).getReverseColumnNameAlias().getReference());
}
public JdbcBackReferencePropertyValueProvider extendBy(RelationalPersistentProperty property) {

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

@ -24,6 +24,7 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing; @@ -24,6 +24,7 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing;
* {@link PropertyValueProvider} obtaining values from a {@link ResultSetAccessor}.
*
* @author Jens Schauder
* @author Kurt Niemi
* @since 2.0
*/
class JdbcPropertyValueProvider implements PropertyValueProvider<RelationalPersistentProperty> {

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

@ -57,6 +57,7 @@ import org.springframework.util.Assert; @@ -57,6 +57,7 @@ import org.springframework.util.Assert;
* @author Diego Krupitza
* @author Hari Ohm Prasath
* @author Viktor Ardelean
* @author Kurt Niemi
*/
class SqlGenerator {

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

@ -30,6 +30,7 @@ import org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource; @@ -30,6 +30,7 @@ import org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource;
* {@link SqlIdentifier} instead of {@link String} for names.
*
* @author Jens Schauder
* @author Kurt Niemi
* @since 2.0
*/
class SqlIdentifierParameterSource extends AbstractSqlParameterSource {

1
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/H2Dialect.java

@ -27,6 +27,7 @@ import org.springframework.r2dbc.core.binding.BindMarkersFactory; @@ -27,6 +27,7 @@ import org.springframework.r2dbc.core.binding.BindMarkersFactory;
* @author Mark Paluch
* @author Jens Schauder
* @author Diego Krupitza
* @author Kurt Niemi
*/
public class H2Dialect extends org.springframework.data.relational.core.dialect.H2Dialect implements R2dbcDialect {

1
spring-data-r2dbc/src/main/java/org/springframework/data/r2dbc/dialect/MySqlDialect.java

@ -36,6 +36,7 @@ import org.springframework.r2dbc.core.binding.BindMarkersFactory; @@ -36,6 +36,7 @@ import org.springframework.r2dbc.core.binding.BindMarkersFactory;
*
* @author Mark Paluch
* @author Jens Schauder
* @author Kurt Niemi
*/
public class MySqlDialect extends org.springframework.data.relational.core.dialect.MySqlDialect
implements R2dbcDialect {

3
spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/DerivedSqlIdentifier.java

@ -29,6 +29,7 @@ import org.springframework.util.Assert; @@ -29,6 +29,7 @@ import org.springframework.util.Assert;
* {@link NamingStrategy}.
*
* @author Mark Paluch
* @author Kurt Niemi
* @since 2.0
*/
class DerivedSqlIdentifier implements SqlIdentifier {
@ -67,7 +68,7 @@ class DerivedSqlIdentifier implements SqlIdentifier { @@ -67,7 +68,7 @@ class DerivedSqlIdentifier implements SqlIdentifier {
@Override
@Deprecated(since="3.1", forRemoval = true)
public String getReference(IdentifierProcessing processing) {
return toSql(processing);
return this.name;
}
@Override

1
spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/NamingStrategy.java

@ -31,6 +31,7 @@ import org.springframework.util.Assert; @@ -31,6 +31,7 @@ import org.springframework.util.Assert;
* @author Kazuki Shimizu
* @author Jens Schauder
* @author Oliver Gierke
* @author Kurt Niemi
*/
public interface NamingStrategy {

1
spring-data-relational/src/main/java/org/springframework/data/relational/core/mapping/PersistentPropertyPathExtension.java

@ -33,6 +33,7 @@ import org.springframework.util.StringUtils; @@ -33,6 +33,7 @@ import org.springframework.util.StringUtils;
*
* @author Jens Schauder
* @author Daniil Razorenov
* @author Kurt Niemi
* @since 1.1
*/
public class PersistentPropertyPathExtension {

3
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/DefaultSqlIdentifier.java

@ -27,6 +27,7 @@ import org.springframework.util.Assert; @@ -27,6 +27,7 @@ import org.springframework.util.Assert;
*
* @author Jens Schauder
* @author Mark Paluch
* @author Kurt Niemi
* @since 2.0
*/
class DefaultSqlIdentifier implements SqlIdentifier {
@ -63,7 +64,7 @@ class DefaultSqlIdentifier implements SqlIdentifier { @@ -63,7 +64,7 @@ class DefaultSqlIdentifier implements SqlIdentifier {
@Override
@Deprecated(since="3.1", forRemoval = true)
public String getReference(IdentifierProcessing processing) {
return toSql(processing);
return name;
}
@Override

21
spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/SqlIdentifier.java

@ -25,10 +25,9 @@ import org.springframework.data.util.Streamable; @@ -25,10 +25,9 @@ import org.springframework.data.util.Streamable;
* Represents a named object that exists in the database like a table name or a column name. SQL identifiers are created
* 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()} 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.
* {@link SqlIdentifier} renders its name using {@link IdentifierProcessing} rules. Use {@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>
* {@link SqlIdentifier} objects are immutable. Calling transformational methods such as
* {@link #transform(UnaryOperator)} creates a new instance.
@ -82,14 +81,14 @@ public interface SqlIdentifier extends Streamable<SqlIdentifier> { @@ -82,14 +81,14 @@ public interface SqlIdentifier extends Streamable<SqlIdentifier> {
* @return
* @deprecated since 3.1, use the #getReference() method instead.
*/
@Deprecated(since="3.1", forRemoval = true)
@Deprecated(since = "3.1", forRemoval = true)
String getReference(IdentifierProcessing processing);
/**
* 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}.
* 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.
*
* @return
* @return the string representation of the identifier, which may be used to access columns in a {@link java.sql.ResultSet}
* @see IdentifierProcessing#NONE
*/
default String getReference() {
@ -98,7 +97,11 @@ public interface SqlIdentifier extends Streamable<SqlIdentifier> { @@ -98,7 +97,11 @@ public interface SqlIdentifier extends Streamable<SqlIdentifier> {
/**
* Use this method when rendering an identifier in SQL statements as in:
* <pre><code>select yourColumn from someTable</code></pre>
*
* <pre>
* <code>select yourColumn from someTable</code>
* </pre>
*
* {@link IdentifierProcessing} rules are applied to the identifier.
*
* @param processing identifier processing rules.

5
spring-data-relational/src/test/java/org/springframework/data/relational/core/mapping/DerivedSqlIdentifierUnitTests.java

@ -29,6 +29,7 @@ import org.springframework.data.relational.core.sql.SqlIdentifier; @@ -29,6 +29,7 @@ import org.springframework.data.relational.core.sql.SqlIdentifier;
*
* @author Jens Schauder
* @author Mark Paluch
* @author Kurt Niemi
*/
public class DerivedSqlIdentifierUnitTests {
@ -41,7 +42,7 @@ public class DerivedSqlIdentifierUnitTests { @@ -41,7 +42,7 @@ public class DerivedSqlIdentifierUnitTests {
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");
}
@ -53,7 +54,7 @@ public class DerivedSqlIdentifierUnitTests { @@ -53,7 +54,7 @@ public class DerivedSqlIdentifierUnitTests {
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");
}

3
spring-data-relational/src/test/java/org/springframework/data/relational/core/sql/SqlIdentifierUnitTests.java

@ -28,6 +28,7 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing.Quoting @@ -28,6 +28,7 @@ import org.springframework.data.relational.core.sql.IdentifierProcessing.Quoting
*
* @author Jens Schauder
* @author Mark Paluch
* @author Kurt Niemi
*/
public class SqlIdentifierUnitTests {
@ -40,7 +41,7 @@ public class SqlIdentifierUnitTests { @@ -40,7 +41,7 @@ public class SqlIdentifierUnitTests {
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");
}

Loading…
Cancel
Save