Skip to content

Commit 3ca3d71

Browse files
committed
Deprecate redundant getReference(IdentifierProcessing) method
The method also fixed the bug of this method not honoring the IdentifierProcessing parameter, so the functionality is now identical to the toSql(IdentifierProcessing) method. Closes spring-projects#1110
1 parent aabca9d commit 3ca3d71

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ public String toSql(IdentifierProcessing processing) {
6565
}
6666

6767
@Override
68+
@Deprecated(since="3.0.5", forRemoval = false)
6869
public String getReference(IdentifierProcessing processing) {
69-
return this.name;
70+
return toSql(processing);
7071
}
7172

7273
@Override

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

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public String toSql(IdentifierProcessing processing) {
6666
}
6767

6868
@Override
69+
@Deprecated(since="3.0.5", forRemoval = false)
6970
public String getReference(IdentifierProcessing processing) {
7071
throw new UnsupportedOperationException("Composite SQL Identifiers can't be used for reference name retrieval");
7172
}

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ public SqlIdentifier transform(UnaryOperator<String> transformationFunction) {
5757

5858
@Override
5959
public String toSql(IdentifierProcessing processing) {
60-
return quoted ? processing.quote(getReference(processing)) : getReference(processing);
60+
return quoted ? processing.quote(name) : name;
6161
}
6262

6363
@Override
64+
@Deprecated(since="3.0.5", forRemoval = false)
6465
public String getReference(IdentifierProcessing processing) {
65-
return name;
66+
return toSql(processing);
6667
}
6768

6869
@Override

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* from a {@link String name} with specifying whether the name should be quoted or unquoted.
2727
* <p>
2828
* {@link SqlIdentifier} renders its name using {@link IdentifierProcessing} rules. Use
29-
* {@link #getReference(IdentifierProcessing)} to refer to an object using the identifier when e.g. obtaining values
29+
* {@link #getReference()} to refer to an object using the identifier when e.g. obtaining values
3030
* from a result or providing values for a prepared statement. {@link #toSql(IdentifierProcessing)} renders the
3131
* identifier for SQL statement usage.
3232
* <p>
@@ -39,6 +39,7 @@
3939
*
4040
* @author Jens Schauder
4141
* @author Mark Paluch
42+
* @author Kurt Niemi
4243
* @since 2.0
4344
*/
4445
public interface SqlIdentifier extends Streamable<SqlIdentifier> {
@@ -77,9 +78,12 @@ public String toString() {
7778
* Return the reference name after applying {@link IdentifierProcessing} rules. The reference name is used for
7879
* programmatic access to the object identified by this {@link SqlIdentifier}.
7980
*
81+
* @deprecated Use the toSql(IdentifierProcessing processing) method instead.
82+
*
8083
* @param processing identifier processing rules.
8184
* @return
8285
*/
86+
@Deprecated(since="3.0.5", forRemoval = false)
8387
String getReference(IdentifierProcessing processing);
8488

8589
/**
@@ -90,7 +94,7 @@ public String toString() {
9094
* @see IdentifierProcessing#NONE
9195
*/
9296
default String getReference() {
93-
return getReference(IdentifierProcessing.NONE);
97+
return toSql(IdentifierProcessing.NONE);
9498
}
9599

96100
/**

0 commit comments

Comments
 (0)