Polishing.
Added `@author` tags. Undo the change in behaviour of getReference(IdentifierProcessing). See #1110 Original pull request #1458
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@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) {
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.springframework.util.Assert;
|
||||
* @author Diego Krupitza
|
||||
* @author Hari Ohm Prasath
|
||||
* @author Viktor Ardelean
|
||||
* @author Kurt Niemi
|
||||
*/
|
||||
class SqlGenerator {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
@Override
|
||||
@Deprecated(since="3.1", forRemoval = true)
|
||||
public String getReference(IdentifierProcessing processing) {
|
||||
return toSql(processing);
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.util.Assert;
|
||||
* @author Kazuki Shimizu
|
||||
* @author Jens Schauder
|
||||
* @author Oliver Gierke
|
||||
* @author Kurt Niemi
|
||||
*/
|
||||
public interface NamingStrategy {
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @author Daniil Razorenov
|
||||
* @author Kurt Niemi
|
||||
* @since 1.1
|
||||
*/
|
||||
public class PersistentPropertyPathExtension {
|
||||
|
||||
@@ -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 {
|
||||
@Override
|
||||
@Deprecated(since="3.1", forRemoval = true)
|
||||
public String getReference(IdentifierProcessing processing) {
|
||||
return toSql(processing);
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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> {
|
||||
* @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> {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -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 {
|
||||
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 {
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user