Ensure configuration methods in SimpleJdbcInsert support method chaining
Prior to this commit, the withoutTableColumnMetaDataAccess() and includeSynonymsForTableColumnMetaData() methods in SimpleJdbcInsert incorrectly declared a SimpleJdbcInsertOperations return type, which prevented method chaining when the instance was declared to be of type SimpleJdbcInsert. This commit changes the return types of those methods to SimpleJdbcInsert to benefit from covariant return types like the rest of the configuration methods in SimpleJdbcInsert. Closes gh-31177
This commit is contained in:
parent
0a7166234d
commit
734d113b11
|
|
@ -109,13 +109,13 @@ public class SimpleJdbcInsert extends AbstractJdbcInsert implements SimpleJdbcIn
|
|||
}
|
||||
|
||||
@Override
|
||||
public SimpleJdbcInsertOperations withoutTableColumnMetaDataAccess() {
|
||||
public SimpleJdbcInsert withoutTableColumnMetaDataAccess() {
|
||||
setAccessTableColumnMetaData(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleJdbcInsertOperations includeSynonymsForTableColumnMetaData() {
|
||||
public SimpleJdbcInsert includeSynonymsForTableColumnMetaData() {
|
||||
setOverrideIncludeSynonymsDefault(true);
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,28 @@ class SimpleJdbcInsertTests {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method does not test any functionality but rather only that
|
||||
* configuration methods can be chained without compiler errors.
|
||||
*/
|
||||
@Test // gh-31177
|
||||
void methodChaining() throws Exception {
|
||||
SimpleJdbcInsert insert = new SimpleJdbcInsert(dataSource)
|
||||
.withCatalogName("my_catalog")
|
||||
.withSchemaName("my_schema")
|
||||
.withTableName("my_table")
|
||||
.usingColumns("col1", "col2")
|
||||
.usingGeneratedKeyColumns("id")
|
||||
.usingQuotedIdentifiers()
|
||||
.withoutTableColumnMetaDataAccess()
|
||||
.includeSynonymsForTableColumnMetaData();
|
||||
|
||||
assertThat(insert).isNotNull();
|
||||
|
||||
// Satisfy the @AfterEach mock verification.
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void noSuchTable() throws Exception {
|
||||
ResultSet resultSet = mock();
|
||||
|
|
|
|||
Loading…
Reference in New Issue