Skip to content

Commit c0d98fc

Browse files
committed
Consistent Object result declarations for ResultQuerySpec
Closes gh-31403
1 parent de6692e commit c0d98fc

File tree

4 files changed

+134
-123
lines changed

4 files changed

+134
-123
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/DefaultJdbcClient.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,9 @@ public Map<String, Object> singleRow() {
285285
return classicOps.queryForMap(sql, indexedParams.toArray());
286286
}
287287

288-
@SuppressWarnings("unchecked")
289288
@Override
290-
public <T> List<T> singleColumn() {
291-
return (List<T>) classicOps.queryForList(sql, Object.class, indexedParams.toArray());
289+
public List<Object> singleColumn() {
290+
return classicOps.queryForList(sql, Object.class, indexedParams.toArray());
292291
}
293292
}
294293

@@ -310,10 +309,9 @@ public Map<String, Object> singleRow() {
310309
return namedParamOps.queryForMap(sql, namedParamSource);
311310
}
312311

313-
@SuppressWarnings("unchecked")
314312
@Override
315-
public <T> List<T> singleColumn() {
316-
return (List<T>) namedParamOps.queryForList(sql, namedParamSource, Object.class);
313+
public List<Object> singleColumn() {
314+
return namedParamOps.queryForList(sql, namedParamSource, Object.class);
317315
}
318316
}
319317

spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/JdbcClient.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,17 +323,16 @@ interface ResultQuerySpec {
323323
* Retrieve a single column result,
324324
* retaining the order from the original database result.
325325
* @return a (potentially empty) list of rows, with each
326-
* row represented as a column value of the given type
326+
* row represented as its single column value
327327
*/
328-
<T> List<T> singleColumn();
328+
List<Object> singleColumn();
329329

330330
/**
331331
* Retrieve a single value result.
332-
* @return the single row represented as its single
333-
* column value of the given type
332+
* @return the single row represented as its single column value
334333
* @see DataAccessUtils#requiredSingleResult(Collection)
335334
*/
336-
default <T> T singleValue() {
335+
default Object singleValue() {
337336
return DataAccessUtils.requiredSingleResult(singleColumn());
338337
}
339338
}

spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/JdbcClientIndexedParameterTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void setup() throws Exception {
9595

9696

9797
@Test
98-
public void testQueryWithResultSetExtractor() throws SQLException {
98+
public void queryWithResultSetExtractor() throws SQLException {
9999
given(resultSet.next()).willReturn(true);
100100
given(resultSet.getInt("id")).willReturn(1);
101101
given(resultSet.getString("forename")).willReturn("rod");
@@ -122,7 +122,7 @@ public void testQueryWithResultSetExtractor() throws SQLException {
122122
}
123123

124124
@Test
125-
public void testQueryWithResultSetExtractorNoParameters() throws SQLException {
125+
public void queryWithResultSetExtractorNoParameters() throws SQLException {
126126
given(resultSet.next()).willReturn(true);
127127
given(resultSet.getInt("id")).willReturn(1);
128128
given(resultSet.getString("forename")).willReturn("rod");
@@ -145,7 +145,7 @@ public void testQueryWithResultSetExtractorNoParameters() throws SQLException {
145145
}
146146

147147
@Test
148-
public void testQueryWithRowCallbackHandler() throws SQLException {
148+
public void queryWithRowCallbackHandler() throws SQLException {
149149
given(resultSet.next()).willReturn(true, false);
150150
given(resultSet.getInt("id")).willReturn(1);
151151
given(resultSet.getString("forename")).willReturn("rod");
@@ -172,7 +172,7 @@ public void testQueryWithRowCallbackHandler() throws SQLException {
172172
}
173173

174174
@Test
175-
public void testQueryWithRowCallbackHandlerNoParameters() throws SQLException {
175+
public void queryWithRowCallbackHandlerNoParameters() throws SQLException {
176176
given(resultSet.next()).willReturn(true, false);
177177
given(resultSet.getInt("id")).willReturn(1);
178178
given(resultSet.getString("forename")).willReturn("rod");
@@ -195,7 +195,7 @@ public void testQueryWithRowCallbackHandlerNoParameters() throws SQLException {
195195
}
196196

197197
@Test
198-
public void testQueryWithRowMapper() throws SQLException {
198+
public void queryWithRowMapper() throws SQLException {
199199
given(resultSet.next()).willReturn(true, false);
200200
given(resultSet.getInt("id")).willReturn(1);
201201
given(resultSet.getString("forename")).willReturn("rod");
@@ -223,7 +223,7 @@ public void testQueryWithRowMapper() throws SQLException {
223223
}
224224

225225
@Test
226-
public void testQueryWithRowMapperNoParameters() throws SQLException {
226+
public void queryWithRowMapperNoParameters() throws SQLException {
227227
given(resultSet.next()).willReturn(true, false);
228228
given(resultSet.getInt("id")).willReturn(1);
229229
given(resultSet.getString("forename")).willReturn("rod");
@@ -247,7 +247,7 @@ public void testQueryWithRowMapperNoParameters() throws SQLException {
247247
}
248248

249249
@Test
250-
public void testQueryForObjectWithRowMapper() throws SQLException {
250+
public void queryForObjectWithRowMapper() throws SQLException {
251251
given(resultSet.next()).willReturn(true, false);
252252
given(resultSet.getInt("id")).willReturn(1);
253253
given(resultSet.getString("forename")).willReturn("rod");
@@ -274,7 +274,7 @@ public void testQueryForObjectWithRowMapper() throws SQLException {
274274
}
275275

276276
@Test
277-
public void testQueryForStreamWithRowMapper() throws SQLException {
277+
public void queryForStreamWithRowMapper() throws SQLException {
278278
given(resultSet.next()).willReturn(true, false);
279279
given(resultSet.getInt("id")).willReturn(1);
280280
given(resultSet.getString("forename")).willReturn("rod");
@@ -307,7 +307,7 @@ public void testQueryForStreamWithRowMapper() throws SQLException {
307307
}
308308

309309
@Test
310-
public void testUpdate() throws SQLException {
310+
public void update() throws SQLException {
311311
given(preparedStatement.executeUpdate()).willReturn(1);
312312

313313
params.add(1);
@@ -323,7 +323,7 @@ public void testUpdate() throws SQLException {
323323
}
324324

325325
@Test
326-
public void testUpdateWithTypedParameters() throws SQLException {
326+
public void updateWithTypedParameters() throws SQLException {
327327
given(preparedStatement.executeUpdate()).willReturn(1);
328328

329329
params.add(new SqlParameterValue(Types.DECIMAL, 1));
@@ -339,7 +339,7 @@ public void testUpdateWithTypedParameters() throws SQLException {
339339
}
340340

341341
@Test
342-
public void testUpdateAndGeneratedKeys() throws SQLException {
342+
public void updateAndGeneratedKeys() throws SQLException {
343343
given(resultSetMetaData.getColumnCount()).willReturn(1);
344344
given(resultSetMetaData.getColumnLabel(1)).willReturn("1");
345345
given(resultSet.getMetaData()).willReturn(resultSetMetaData);

0 commit comments

Comments
 (0)