2222import java .util .function .Function ;
2323
2424import org .apache .ibatis .annotations .SelectProvider ;
25+ import org .jspecify .annotations .Nullable ;
2526import org .mybatis .dynamic .sql .select .render .SelectStatementProvider ;
2627import org .mybatis .dynamic .sql .util .SqlProviderAdapter ;
2728
@@ -58,7 +59,7 @@ public interface CommonSelectMapper {
5859 * @return A Map containing the row values.
5960 */
6061 @ SelectProvider (type = SqlProviderAdapter .class , method = "select" )
61- Map <String , Object > selectOneMappedRow (SelectStatementProvider selectStatement );
62+ @ Nullable Map <String , Object > selectOneMappedRow (SelectStatementProvider selectStatement );
6263
6364 /**
6465 * Select a single row of values and then convert the values to a custom type. This is similar
@@ -74,9 +75,10 @@ public interface CommonSelectMapper {
7475 * @param <R> the datatype of the converted object
7576 * @return the converted object
7677 */
77- default <R > R selectOne (SelectStatementProvider selectStatement ,
78+ default <R > @ Nullable R selectOne (SelectStatementProvider selectStatement ,
7879 Function <Map <String , Object >, R > rowMapper ) {
79- return rowMapper .apply (selectOneMappedRow (selectStatement ));
80+ var result = selectOneMappedRow (selectStatement );
81+ return result == null ? null : rowMapper .apply (result );
8082 }
8183
8284 /**
@@ -122,7 +124,7 @@ default <R> List<R> selectMany(SelectStatementProvider selectStatement,
122124 * column is null
123125 */
124126 @ SelectProvider (type = SqlProviderAdapter .class , method = "select" )
125- BigDecimal selectOneBigDecimal (SelectStatementProvider selectStatement );
127+ @ Nullable BigDecimal selectOneBigDecimal (SelectStatementProvider selectStatement );
126128
127129 /**
128130 * Retrieve a single {@link java.math.BigDecimal} from a result set. The result set must have
@@ -157,7 +159,7 @@ default <R> List<R> selectMany(SelectStatementProvider selectStatement,
157159 * column is null
158160 */
159161 @ SelectProvider (type = SqlProviderAdapter .class , method = "select" )
160- Double selectOneDouble (SelectStatementProvider selectStatement );
162+ @ Nullable Double selectOneDouble (SelectStatementProvider selectStatement );
161163
162164 /**
163165 * Retrieve a single {@link java.lang.Double} from a result set. The result set must have
@@ -192,7 +194,7 @@ default <R> List<R> selectMany(SelectStatementProvider selectStatement,
192194 * column is null
193195 */
194196 @ SelectProvider (type = SqlProviderAdapter .class , method = "select" )
195- Integer selectOneInteger (SelectStatementProvider selectStatement );
197+ @ Nullable Integer selectOneInteger (SelectStatementProvider selectStatement );
196198
197199 /**
198200 * Retrieve a single {@link java.lang.Integer} from a result set. The result set must have
@@ -227,7 +229,7 @@ default <R> List<R> selectMany(SelectStatementProvider selectStatement,
227229 * column is null
228230 */
229231 @ SelectProvider (type = SqlProviderAdapter .class , method = "select" )
230- Long selectOneLong (SelectStatementProvider selectStatement );
232+ @ Nullable Long selectOneLong (SelectStatementProvider selectStatement );
231233
232234 /**
233235 * Retrieve a single {@link java.lang.Long} from a result set. The result set must have
@@ -262,7 +264,7 @@ default <R> List<R> selectMany(SelectStatementProvider selectStatement,
262264 * column is null
263265 */
264266 @ SelectProvider (type = SqlProviderAdapter .class , method = "select" )
265- String selectOneString (SelectStatementProvider selectStatement );
267+ @ Nullable String selectOneString (SelectStatementProvider selectStatement );
266268
267269 /**
268270 * Retrieve a single {@link java.lang.String} from a result set. The result set must have
0 commit comments