Skip to content

Commit 7b8c1bb

Browse files
committed
Polishing.
Rename method to renderForGeneratedValues to reflect its intended usage and enhance documentation. Tweak Javadoc. Closes: #483 Original pull request: #602.
1 parent c868257 commit 7b8c1bb

13 files changed

+38
-35
lines changed

src/main/java/org/springframework/data/r2dbc/core/DefaultReactiveDataAccessStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ public R2dbcConverter getConverter() {
362362
}
363363

364364
@Override
365-
public String renderForGeneratedKeys(SqlIdentifier identifier) {
366-
return dialect.renderForGeneratedKeys(identifier);
365+
public String renderForGeneratedValues(SqlIdentifier identifier) {
366+
return dialect.renderForGeneratedValues(identifier);
367367
}
368368

369369
private RelationalPersistentEntity<?> getRequiredPersistentEntity(Class<?> typeToRead) {

src/main/java/org/springframework/data/r2dbc/core/R2dbcEntityTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ private <T> Mono<T> doInsert(T entity, SqlIdentifier tableName, OutboundRow outb
634634
return statement.returnGeneratedValues();
635635
}
636636

637-
return statement.returnGeneratedValues(dataAccessStrategy.renderForGeneratedKeys(identifierColumns.get(0)));
637+
return statement.returnGeneratedValues(dataAccessStrategy.renderForGeneratedValues(identifierColumns.get(0)));
638638
})
639639
.map(this.dataAccessStrategy.getConverter().populateIdIfNecessary(entity)) //
640640
.all() //

src/main/java/org/springframework/data/r2dbc/core/ReactiveDataAccessStrategy.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,16 @@ public interface ReactiveDataAccessStrategy {
138138
String toSql(SqlIdentifier identifier);
139139

140140
/**
141-
* Render a {@link SqlIdentifier} in a way suitable for registering it as a generated key with a statement.
142-
*
141+
* Render a {@link SqlIdentifier} in a way suitable for registering it as a generated key with a statement through
142+
* {@code Statement#returnGeneratedValues}.
143+
*
143144
* @param identifier to render. Must not be {@literal null}.
144145
* @return rendered identifier. Guaranteed to be not {@literal null}.
146+
* @since 1.3.2
145147
*/
146-
default String renderForGeneratedKeys(SqlIdentifier identifier) {
148+
default String renderForGeneratedValues(SqlIdentifier identifier) {
147149

148-
Assert.notNull(identifier, "Indentifier must not be null.");
150+
Assert.notNull(identifier, "SqlIdentifier must not be null.");
149151

150152
return identifier.toSql(IdentifierProcessing.NONE);
151153
}

src/main/java/org/springframework/data/r2dbc/dialect/H2Dialect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class H2Dialect extends PostgresDialect {
1616
public static final H2Dialect INSTANCE = new H2Dialect();
1717

1818
@Override
19-
public String renderForGeneratedKeys(SqlIdentifier identifier) {
19+
public String renderForGeneratedValues(SqlIdentifier identifier) {
2020
return identifier.getReference(getIdentifierProcessing());
2121
}
2222
}

src/main/java/org/springframework/data/r2dbc/dialect/MySqlDialect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public Boolean convert(Byte s) {
106106
}
107107

108108
@Override
109-
public String renderForGeneratedKeys(SqlIdentifier identifier) {
109+
public String renderForGeneratedValues(SqlIdentifier identifier) {
110110
return identifier.getReference(getIdentifierProcessing());
111111
}
112112

src/main/java/org/springframework/data/r2dbc/dialect/R2dbcDialect.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,15 @@ default Collection<Object> getConverters() {
6262
}
6363

6464
/**
65-
* Render a {@link SqlIdentifier} in a way suitable for registering it as a generated key with a statement. The
66-
* default implementation renders it as it would render a SQL representation of the identifier, i.e. with quotes where
67-
* applicable.
65+
* Render a {@link SqlIdentifier} in a way suitable for registering it as a generated key with a statement through
66+
* {@code Statement#returnGeneratedValues}. The default implementation renders it as it would render a SQL
67+
* representation of the identifier, i.e. with quotes where applicable.
6868
*
6969
* @param identifier to render. Must not be {@literal null}.
7070
* @return rendered identifier. Guaranteed to be not {@literal null}.
71+
* @since 1.3.2
7172
*/
72-
default String renderForGeneratedKeys(SqlIdentifier identifier) {
73+
default String renderForGeneratedValues(SqlIdentifier identifier) {
7374
return identifier.toSql(getIdentifierProcessing());
7475
}
7576
}

src/test/java/org/springframework/data/r2dbc/repository/H2R2dbcRepositoryWithMixedCaseNamesIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.springframework.test.context.junit.jupiter.SpringExtension;
3737

3838
/**
39-
* Integration tests for {@link LegoSetRepository} with table and column names that contain * upper and lower case
39+
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
4040
* characters against H2.
4141
*
4242
* @author Jens Schauder

src/test/java/org/springframework/data/r2dbc/repository/MariaDbR2dbcRepositoryWithMixedCaseNamesIntegrationTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@
3838
import org.springframework.test.context.junit.jupiter.SpringExtension;
3939

4040
/**
41-
* Integration tests for {@link LegoSetRepository} with table and column names that contain * upper and lower case
41+
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
4242
* characters against MariaDb.
4343
*
44-
* @author Mark Paluch
45-
* @author Zsombor Gegesy
44+
* @author Jens Schauder
4645
*/
4746
@ExtendWith(SpringExtension.class)
4847
@ContextConfiguration

src/test/java/org/springframework/data/r2dbc/repository/MySqlR2dbcRepositoryWithMixedCaseNamesIntegrationTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,26 @@
2323

2424
import org.junit.jupiter.api.extension.ExtendWith;
2525
import org.junit.jupiter.api.extension.RegisterExtension;
26+
2627
import org.springframework.context.annotation.Bean;
28+
import org.springframework.context.annotation.ComponentScan.Filter;
2729
import org.springframework.context.annotation.Configuration;
2830
import org.springframework.context.annotation.FilterType;
29-
import org.springframework.context.annotation.ComponentScan.Filter;
3031
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
3132
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
3233
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
3334
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
34-
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
3535
import org.springframework.data.r2dbc.testing.ExternalDatabase;
3636
import org.springframework.data.r2dbc.testing.MySqlTestSupport;
3737
import org.springframework.data.relational.core.mapping.NamingStrategy;
3838
import org.springframework.test.context.ContextConfiguration;
3939
import org.springframework.test.context.junit.jupiter.SpringExtension;
4040

4141
/**
42-
* Integration tests for {@link LegoSetRepository} with table and column names that contain
43-
* * upper and lower case characters against MySql.
42+
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
43+
* characters against MySql.
4444
*
45-
* @author Mark Paluch
46-
* @author Zsombor Gegesy
45+
* @author Jens Schauder
4746
*/
4847
@ExtendWith(SpringExtension.class)
4948
@ContextConfiguration

src/test/java/org/springframework/data/r2dbc/repository/OracleR2dbcRepositoryWithMixedCaseNamesIntegrationTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.junit.jupiter.api.extension.ExtendWith;
2525
import org.junit.jupiter.api.extension.RegisterExtension;
26+
2627
import org.springframework.context.annotation.Bean;
2728
import org.springframework.context.annotation.ComponentScan.Filter;
2829
import org.springframework.context.annotation.Configuration;
@@ -31,21 +32,22 @@
3132
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
3233
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
3334
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
34-
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
35+
import org.springframework.data.r2dbc.testing.EnabledOnClass;
3536
import org.springframework.data.r2dbc.testing.ExternalDatabase;
3637
import org.springframework.data.r2dbc.testing.OracleTestSupport;
3738
import org.springframework.data.relational.core.mapping.NamingStrategy;
3839
import org.springframework.test.context.ContextConfiguration;
3940
import org.springframework.test.context.junit.jupiter.SpringExtension;
4041

4142
/**
42-
* Integration tests for {@link LegoSetRepository} with table and column names that contain
43-
* * upper and lower case characters against Oracle.
43+
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
44+
* characters against Oracle.
4445
*
4546
* @author Jens Schauder
4647
*/
4748
@ExtendWith(SpringExtension.class)
4849
@ContextConfiguration
50+
@EnabledOnClass("oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl")
4951
public class OracleR2dbcRepositoryWithMixedCaseNamesIntegrationTests
5052
extends AbstractR2dbcRepositoryWithMixedCaseNamesIntegrationTests {
5153

src/test/java/org/springframework/data/r2dbc/repository/PostgresR2dbcRepositoryWithMixedCaseNamesIntegrationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@
2323

2424
import org.junit.jupiter.api.extension.ExtendWith;
2525
import org.junit.jupiter.api.extension.RegisterExtension;
26+
2627
import org.springframework.context.annotation.Bean;
28+
import org.springframework.context.annotation.ComponentScan.Filter;
2729
import org.springframework.context.annotation.Configuration;
2830
import org.springframework.context.annotation.FilterType;
29-
import org.springframework.context.annotation.ComponentScan.Filter;
3031
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
3132
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
3233
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
3334
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
34-
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
3535
import org.springframework.data.r2dbc.testing.ExternalDatabase;
3636
import org.springframework.data.r2dbc.testing.PostgresTestSupport;
3737
import org.springframework.data.relational.core.mapping.NamingStrategy;
3838
import org.springframework.test.context.ContextConfiguration;
3939
import org.springframework.test.context.junit.jupiter.SpringExtension;
4040

4141
/**
42-
* Integration tests for {@link LegoSetRepository} with table and column names that contain
43-
* * upper and lower case characters against Postgres.
42+
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
43+
* characters against Postgres.
4444
*
4545
* @author Jens Schauder
4646
*/

src/test/java/org/springframework/data/r2dbc/repository/SqlServerR2dbcRepositoryWithMixedCaseNamesIntegrationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.junit.jupiter.api.extension.ExtendWith;
2525
import org.junit.jupiter.api.extension.RegisterExtension;
26+
2627
import org.springframework.context.annotation.Bean;
2728
import org.springframework.context.annotation.ComponentScan.Filter;
2829
import org.springframework.context.annotation.Configuration;
@@ -31,16 +32,15 @@
3132
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
3233
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
3334
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
34-
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
3535
import org.springframework.data.r2dbc.testing.ExternalDatabase;
3636
import org.springframework.data.r2dbc.testing.SqlServerTestSupport;
3737
import org.springframework.data.relational.core.mapping.NamingStrategy;
3838
import org.springframework.test.context.ContextConfiguration;
3939
import org.springframework.test.context.junit.jupiter.SpringExtension;
4040

4141
/**
42-
* Integration tests for {@link LegoSetRepository} with table and column names that contain
43-
* * upper and lower case characters against SQL-Server.
42+
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
43+
* characters against SQL-Server.
4444
*
4545
* @author Jens Schauder
4646
*/

src/test/java/org/springframework/data/r2dbc/testing/ExternalDatabase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,15 @@ boolean checkValidity() {
222222
*/
223223
@Override
224224
public String getHostname() {
225-
return "unknown";
225+
throw new UnsupportedOperationException(getClass().getSimpleName());
226226
}
227227

228228
/* (non-Javadoc)
229229
* @see org.springframework.data.jdbc.core.function.ExternalDatabase#getPort()
230230
*/
231231
@Override
232232
public int getPort() {
233-
return -99999;
233+
throw new UnsupportedOperationException(getClass().getSimpleName());
234234
}
235235

236236
/* (non-Javadoc)

0 commit comments

Comments
 (0)