1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
22
22
import java .util .stream .Stream ;
23
23
24
24
import org .springframework .dao .DataAccessException ;
25
- import org .springframework .dao .IncorrectResultSizeDataAccessException ;
26
25
import org .springframework .jdbc .support .KeyHolder ;
27
26
import org .springframework .jdbc .support .rowset .SqlRowSet ;
28
27
import org .springframework .lang .Nullable ;
29
28
30
29
/**
31
30
* Interface specifying a basic set of JDBC operations.
32
- * Implemented by {@link JdbcTemplate}. Not often used directly, but a useful
31
+ *
32
+ * <p>Implemented by {@link JdbcTemplate}. Not often used directly, but a useful
33
33
* option to enhance testability, as it can easily be mocked or stubbed.
34
34
*
35
35
* <p>Alternatively, the standard JDBC infrastructure can be mocked.
36
36
* However, mocking this interface constitutes significantly less work.
37
37
* As an alternative to a mock objects approach to testing data access code,
38
- * consider the powerful integration testing support provided in the
39
- * {@code org.springframework.test} package, shipped in
40
- * {@code spring-test.jar}.
38
+ * consider the powerful integration testing support provided via the <em>Spring
39
+ * TestContext Framework</em>, in the {@code spring-test} artifact.
41
40
*
42
41
* @author Rod Johnson
43
42
* @author Juergen Hoeller
@@ -160,8 +159,8 @@ public interface JdbcOperations {
160
159
* @param rowMapper a callback that will map one object per row
161
160
* @return the single mapped object (may be {@code null} if the given
162
161
* {@link RowMapper} returned {@code} null)
163
- * @throws IncorrectResultSizeDataAccessException if the query does not
164
- * return exactly one row
162
+ * @throws org.springframework.dao. IncorrectResultSizeDataAccessException
163
+ * if the query does not return exactly one row
165
164
* @throws DataAccessException if there is any problem executing the query
166
165
* @see #queryForObject(String, RowMapper, Object...)
167
166
*/
@@ -180,8 +179,10 @@ public interface JdbcOperations {
180
179
* @param sql the SQL query to execute
181
180
* @param requiredType the type that the result object is expected to match
182
181
* @return the result object of the required type, or {@code null} in case of SQL NULL
183
- * @throws IncorrectResultSizeDataAccessException if the query does not return
184
- * exactly one row, or does not return exactly one column in that row
182
+ * @throws org.springframework.dao.IncorrectResultSizeDataAccessException
183
+ * if the query does not return exactly one row
184
+ * @throws org.springframework.jdbc.IncorrectResultSetColumnCountException
185
+ * if the query does not return a row containing a single column
185
186
* @throws DataAccessException if there is any problem executing the query
186
187
* @see #queryForObject(String, Class, Object...)
187
188
*/
@@ -198,8 +199,8 @@ public interface JdbcOperations {
198
199
* mapped to a Map (one entry for each column, using the column name as the key).
199
200
* @param sql the SQL query to execute
200
201
* @return the result Map (one entry per column, with column name as key)
201
- * @throws IncorrectResultSizeDataAccessException if the query does not
202
- * return exactly one row
202
+ * @throws org.springframework.dao. IncorrectResultSizeDataAccessException
203
+ * if the query does not return exactly one row
203
204
* @throws DataAccessException if there is any problem executing the query
204
205
* @see #queryForMap(String, Object...)
205
206
* @see ColumnMapRowMapper
@@ -603,8 +604,8 @@ <T> Stream<T> queryForStream(String sql, RowMapper<T> rowMapper, @Nullable Objec
603
604
* @param rowMapper a callback that will map one object per row
604
605
* @return the single mapped object (may be {@code null} if the given
605
606
* {@link RowMapper} returned {@code} null)
606
- * @throws IncorrectResultSizeDataAccessException if the query does not
607
- * return exactly one row
607
+ * @throws org.springframework.dao. IncorrectResultSizeDataAccessException
608
+ * if the query does not return exactly one row
608
609
* @throws DataAccessException if the query fails
609
610
*/
610
611
@ Nullable
@@ -623,8 +624,8 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, RowMapper<T> row
623
624
* @param rowMapper a callback that will map one object per row
624
625
* @return the single mapped object (may be {@code null} if the given
625
626
* {@link RowMapper} returned {@code} null)
626
- * @throws IncorrectResultSizeDataAccessException if the query does not
627
- * return exactly one row
627
+ * @throws org.springframework.dao. IncorrectResultSizeDataAccessException
628
+ * if the query does not return exactly one row
628
629
* @throws DataAccessException if the query fails
629
630
* @deprecated as of 5.3, in favor of {@link #queryForObject(String, RowMapper, Object...)}
630
631
*/
@@ -644,8 +645,8 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, RowMapper<T> row
644
645
* only the argument value but also the SQL type and optionally the scale
645
646
* @return the single mapped object (may be {@code null} if the given
646
647
* {@link RowMapper} returned {@code} null)
647
- * @throws IncorrectResultSizeDataAccessException if the query does not
648
- * return exactly one row
648
+ * @throws org.springframework.dao. IncorrectResultSizeDataAccessException
649
+ * if the query does not return exactly one row
649
650
* @throws DataAccessException if the query fails
650
651
* @since 3.0.1
651
652
*/
@@ -663,8 +664,10 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, RowMapper<T> row
663
664
* (constants from {@code java.sql.Types})
664
665
* @param requiredType the type that the result object is expected to match
665
666
* @return the result object of the required type, or {@code null} in case of SQL NULL
666
- * @throws IncorrectResultSizeDataAccessException if the query does not return
667
- * exactly one row, or does not return exactly one column in that row
667
+ * @throws org.springframework.dao.IncorrectResultSizeDataAccessException
668
+ * if the query does not return exactly one row
669
+ * @throws org.springframework.jdbc.IncorrectResultSetColumnCountException
670
+ * if the query does not return a row containing a single column
668
671
* @throws DataAccessException if the query fails
669
672
* @see #queryForObject(String, Class)
670
673
* @see java.sql.Types
@@ -685,8 +688,10 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, Class<T> require
685
688
* only the argument value but also the SQL type and optionally the scale
686
689
* @param requiredType the type that the result object is expected to match
687
690
* @return the result object of the required type, or {@code null} in case of SQL NULL
688
- * @throws IncorrectResultSizeDataAccessException if the query does not return
689
- * exactly one row, or does not return exactly one column in that row
691
+ * @throws org.springframework.dao.IncorrectResultSizeDataAccessException
692
+ * if the query does not return exactly one row
693
+ * @throws org.springframework.jdbc.IncorrectResultSetColumnCountException
694
+ * if the query does not return a row containing a single column
690
695
* @throws DataAccessException if the query fails
691
696
* @see #queryForObject(String, Class)
692
697
* @deprecated as of 5.3, in favor of {@link #queryForObject(String, Class, Object...)}
@@ -707,8 +712,10 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, Class<T> require
707
712
* may also contain {@link SqlParameterValue} objects which indicate not
708
713
* only the argument value but also the SQL type and optionally the scale
709
714
* @return the result object of the required type, or {@code null} in case of SQL NULL
710
- * @throws IncorrectResultSizeDataAccessException if the query does not return
711
- * exactly one row, or does not return exactly one column in that row
715
+ * @throws org.springframework.dao.IncorrectResultSizeDataAccessException
716
+ * if the query does not return exactly one row
717
+ * @throws org.springframework.jdbc.IncorrectResultSetColumnCountException
718
+ * if the query does not return a row containing a single column
712
719
* @throws DataAccessException if the query fails
713
720
* @since 3.0.1
714
721
* @see #queryForObject(String, Class)
@@ -726,8 +733,8 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, Class<T> require
726
733
* @param argTypes the SQL types of the arguments
727
734
* (constants from {@code java.sql.Types})
728
735
* @return the result Map (one entry per column, with column name as key)
729
- * @throws IncorrectResultSizeDataAccessException if the query does not
730
- * return exactly one row
736
+ * @throws org.springframework.dao. IncorrectResultSizeDataAccessException
737
+ * if the query does not return exactly one row
731
738
* @throws DataAccessException if the query fails
732
739
* @see #queryForMap(String)
733
740
* @see ColumnMapRowMapper
@@ -750,8 +757,8 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, Class<T> require
750
757
* only the argument value but also the SQL type and optionally the scale
751
758
* @return the result Map (one entry for each column, using the
752
759
* column name as the key)
753
- * @throws IncorrectResultSizeDataAccessException if the query does not
754
- * return exactly one row
760
+ * @throws org.springframework.dao. IncorrectResultSizeDataAccessException
761
+ * if the query does not return exactly one row
755
762
* @throws DataAccessException if the query fails
756
763
* @see #queryForMap(String)
757
764
* @see ColumnMapRowMapper
0 commit comments