Skip to content

Commit 2515015

Browse files
committed
Consistent nullability of arguments array in JdbcOperations/Template
Closes spring-projectsgh-24839
1 parent 6177e38 commit 2515015

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -353,7 +353,7 @@ public interface JdbcOperations {
353353
* @throws DataAccessException if the query fails
354354
*/
355355
@Nullable
356-
<T> T query(String sql, Object[] args, ResultSetExtractor<T> rse) throws DataAccessException;
356+
<T> T query(String sql, @Nullable Object[] args, ResultSetExtractor<T> rse) throws DataAccessException;
357357

358358
/**
359359
* Query given SQL to create a prepared statement from SQL and a list of arguments
@@ -423,7 +423,7 @@ public interface JdbcOperations {
423423
* @param rch a callback that will extract results, one row at a time
424424
* @throws DataAccessException if the query fails
425425
*/
426-
void query(String sql, Object[] args, RowCallbackHandler rch) throws DataAccessException;
426+
void query(String sql, @Nullable Object[] args, RowCallbackHandler rch) throws DataAccessException;
427427

428428
/**
429429
* Query given SQL to create a prepared statement from SQL and a list of
@@ -496,7 +496,7 @@ public interface JdbcOperations {
496496
* @return the result List, containing mapped objects
497497
* @throws DataAccessException if the query fails
498498
*/
499-
<T> List<T> query(String sql, Object[] args, RowMapper<T> rowMapper) throws DataAccessException;
499+
<T> List<T> query(String sql, @Nullable Object[] args, RowMapper<T> rowMapper) throws DataAccessException;
500500

501501
/**
502502
* Query given SQL to create a prepared statement from SQL and a list of
@@ -551,7 +551,7 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, RowMapper<T> row
551551
* @throws DataAccessException if the query fails
552552
*/
553553
@Nullable
554-
<T> T queryForObject(String sql, Object[] args, RowMapper<T> rowMapper) throws DataAccessException;
554+
<T> T queryForObject(String sql, @Nullable Object[] args, RowMapper<T> rowMapper) throws DataAccessException;
555555

556556
/**
557557
* Query given SQL to create a prepared statement from SQL and a list
@@ -612,7 +612,7 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, Class<T> require
612612
* @see #queryForObject(String, Class)
613613
*/
614614
@Nullable
615-
<T> T queryForObject(String sql, Object[] args, Class<T> requiredType) throws DataAccessException;
615+
<T> T queryForObject(String sql, @Nullable Object[] args, Class<T> requiredType) throws DataAccessException;
616616

617617
/**
618618
* Query given SQL to create a prepared statement from SQL and a list of
@@ -713,7 +713,7 @@ <T> List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> ele
713713
* @see #queryForList(String, Class)
714714
* @see SingleColumnRowMapper
715715
*/
716-
<T> List<T> queryForList(String sql, Object[] args, Class<T> elementType) throws DataAccessException;
716+
<T> List<T> queryForList(String sql, @Nullable Object[] args, Class<T> elementType) throws DataAccessException;
717717

718718
/**
719719
* Query given SQL to create a prepared statement from SQL and a list of

spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -734,7 +734,7 @@ public void query(String sql, Object[] args, int[] argTypes, RowCallbackHandler
734734
}
735735

736736
@Override
737-
public void query(String sql, Object[] args, RowCallbackHandler rch) throws DataAccessException {
737+
public void query(String sql, @Nullable Object[] args, RowCallbackHandler rch) throws DataAccessException {
738738
query(sql, newArgPreparedStatementSetter(args), rch);
739739
}
740740

@@ -800,7 +800,7 @@ public <T> T queryForObject(String sql, Object[] args, int[] argTypes, Class<T>
800800
}
801801

802802
@Override
803-
public <T> T queryForObject(String sql, Object[] args, Class<T> requiredType) throws DataAccessException {
803+
public <T> T queryForObject(String sql, @Nullable Object[] args, Class<T> requiredType) throws DataAccessException {
804804
return queryForObject(sql, args, getSingleColumnRowMapper(requiredType));
805805
}
806806

@@ -825,7 +825,7 @@ public <T> List<T> queryForList(String sql, Object[] args, int[] argTypes, Class
825825
}
826826

827827
@Override
828-
public <T> List<T> queryForList(String sql, Object[] args, Class<T> elementType) throws DataAccessException {
828+
public <T> List<T> queryForList(String sql, @Nullable Object[] args, Class<T> elementType) throws DataAccessException {
829829
return query(sql, args, getSingleColumnRowMapper(elementType));
830830
}
831831

0 commit comments

Comments
 (0)