Polishing.

Rename method to renderForGeneratedValues to reflect its intended usage and enhance documentation.

Tweak Javadoc.

Closes: #483
Original pull request: #602.
This commit is contained in:
Mark Paluch
2021-06-11 08:26:19 +02:00
parent efe2514b2e
commit a9de60f164
13 changed files with 38 additions and 35 deletions

View File

@@ -362,8 +362,8 @@ public class DefaultReactiveDataAccessStrategy implements ReactiveDataAccessStra
}
@Override
public String renderForGeneratedKeys(SqlIdentifier identifier) {
return dialect.renderForGeneratedKeys(identifier);
public String renderForGeneratedValues(SqlIdentifier identifier) {
return dialect.renderForGeneratedValues(identifier);
}
private RelationalPersistentEntity<?> getRequiredPersistentEntity(Class<?> typeToRead) {

View File

@@ -605,7 +605,7 @@ public class R2dbcEntityTemplate implements R2dbcEntityOperations, BeanFactoryAw
return statement.returnGeneratedValues();
}
return statement.returnGeneratedValues(dataAccessStrategy.renderForGeneratedKeys(identifierColumns.get(0)));
return statement.returnGeneratedValues(dataAccessStrategy.renderForGeneratedValues(identifierColumns.get(0)));
})
.map(this.dataAccessStrategy.getConverter().populateIdIfNecessary(entity)) //
.all() //

View File

@@ -138,14 +138,16 @@ public interface ReactiveDataAccessStrategy {
String toSql(SqlIdentifier identifier);
/**
* Render a {@link SqlIdentifier} in a way suitable for registering it as a generated key with a statement.
*
* Render a {@link SqlIdentifier} in a way suitable for registering it as a generated key with a statement through
* {@code Statement#returnGeneratedValues}.
*
* @param identifier to render. Must not be {@literal null}.
* @return rendered identifier. Guaranteed to be not {@literal null}.
* @since 1.3.2
*/
default String renderForGeneratedKeys(SqlIdentifier identifier) {
default String renderForGeneratedValues(SqlIdentifier identifier) {
Assert.notNull(identifier, "Indentifier must not be null.");
Assert.notNull(identifier, "SqlIdentifier must not be null.");
return identifier.toSql(IdentifierProcessing.NONE);
}

View File

@@ -16,7 +16,7 @@ public class H2Dialect extends PostgresDialect {
public static final H2Dialect INSTANCE = new H2Dialect();
@Override
public String renderForGeneratedKeys(SqlIdentifier identifier) {
public String renderForGeneratedValues(SqlIdentifier identifier) {
return identifier.getReference(getIdentifierProcessing());
}
}

View File

@@ -106,7 +106,7 @@ public class MySqlDialect extends org.springframework.data.relational.core.diale
}
@Override
public String renderForGeneratedKeys(SqlIdentifier identifier) {
public String renderForGeneratedValues(SqlIdentifier identifier) {
return identifier.getReference(getIdentifierProcessing());
}

View File

@@ -62,14 +62,15 @@ public interface R2dbcDialect extends Dialect {
}
/**
* Render a {@link SqlIdentifier} in a way suitable for registering it as a generated key with a statement. The
* default implementation renders it as it would render a SQL representation of the identifier, i.e. with quotes where
* applicable.
* Render a {@link SqlIdentifier} in a way suitable for registering it as a generated key with a statement through
* {@code Statement#returnGeneratedValues}. The default implementation renders it as it would render a SQL
* representation of the identifier, i.e. with quotes where applicable.
*
* @param identifier to render. Must not be {@literal null}.
* @return rendered identifier. Guaranteed to be not {@literal null}.
* @since 1.3.2
*/
default String renderForGeneratedKeys(SqlIdentifier identifier) {
default String renderForGeneratedValues(SqlIdentifier identifier) {
return identifier.toSql(getIdentifierProcessing());
}
}

View File

@@ -36,7 +36,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Integration tests for {@link LegoSetRepository} with table and column names that contain * upper and lower case
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
* characters against H2.
*
* @author Jens Schauder

View File

@@ -38,11 +38,10 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Integration tests for {@link LegoSetRepository} with table and column names that contain * upper and lower case
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
* characters against MariaDb.
*
* @author Mark Paluch
* @author Zsombor Gegesy
* @author Jens Schauder
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration

View File

@@ -23,15 +23,15 @@ import javax.sql.DataSource;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
import org.springframework.data.r2dbc.testing.ExternalDatabase;
import org.springframework.data.r2dbc.testing.MySqlTestSupport;
import org.springframework.data.relational.core.mapping.NamingStrategy;
@@ -39,11 +39,10 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Integration tests for {@link LegoSetRepository} with table and column names that contain
* * upper and lower case characters against MySql.
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
* characters against MySql.
*
* @author Mark Paluch
* @author Zsombor Gegesy
* @author Jens Schauder
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration

View File

@@ -23,6 +23,7 @@ import javax.sql.DataSource;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
@@ -31,7 +32,7 @@ import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
import org.springframework.data.r2dbc.testing.EnabledOnClass;
import org.springframework.data.r2dbc.testing.ExternalDatabase;
import org.springframework.data.r2dbc.testing.OracleTestSupport;
import org.springframework.data.relational.core.mapping.NamingStrategy;
@@ -39,13 +40,14 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Integration tests for {@link LegoSetRepository} with table and column names that contain
* * upper and lower case characters against Oracle.
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
* characters against Oracle.
*
* @author Jens Schauder
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@EnabledOnClass("oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl")
public class OracleR2dbcRepositoryWithMixedCaseNamesIntegrationTests
extends AbstractR2dbcRepositoryWithMixedCaseNamesIntegrationTests {

View File

@@ -23,15 +23,15 @@ import javax.sql.DataSource;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
import org.springframework.data.r2dbc.testing.ExternalDatabase;
import org.springframework.data.r2dbc.testing.PostgresTestSupport;
import org.springframework.data.relational.core.mapping.NamingStrategy;
@@ -39,8 +39,8 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Integration tests for {@link LegoSetRepository} with table and column names that contain
* * upper and lower case characters against Postgres.
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
* characters against Postgres.
*
* @author Jens Schauder
*/

View File

@@ -23,6 +23,7 @@ import javax.sql.DataSource;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
@@ -31,7 +32,6 @@ import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
import org.springframework.data.r2dbc.convert.R2dbcCustomConversions;
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
import org.springframework.data.r2dbc.repository.support.R2dbcRepositoryFactory;
import org.springframework.data.r2dbc.testing.ExternalDatabase;
import org.springframework.data.r2dbc.testing.SqlServerTestSupport;
import org.springframework.data.relational.core.mapping.NamingStrategy;
@@ -39,8 +39,8 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
* Integration tests for {@link LegoSetRepository} with table and column names that contain
* * upper and lower case characters against SQL-Server.
* Integration tests for {@link LegoSetRepository} with table and column names that contain upper and lower case
* characters against SQL-Server.
*
* @author Jens Schauder
*/

View File

@@ -222,7 +222,7 @@ public abstract class ExternalDatabase implements BeforeAllCallback {
*/
@Override
public String getHostname() {
return "unknown";
throw new UnsupportedOperationException(getClass().getSimpleName());
}
/* (non-Javadoc)
@@ -230,7 +230,7 @@ public abstract class ExternalDatabase implements BeforeAllCallback {
*/
@Override
public int getPort() {
return -99999;
throw new UnsupportedOperationException(getClass().getSimpleName());
}
/* (non-Javadoc)