File tree Expand file tree Collapse file tree 4 files changed +39
-4
lines changed
src/test/java/org/apache/ibatis/submitted/call_setters_on_nulls Expand file tree Collapse file tree 4 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package org .apache .ibatis .submitted .call_setters_on_nulls ;
17
17
18
- import java .io .Reader ;
19
- import java .sql .Connection ;
20
- import java .util .Map ;
21
-
22
18
import org .apache .ibatis .io .Resources ;
23
19
import org .apache .ibatis .jdbc .ScriptRunner ;
24
20
import org .apache .ibatis .session .SqlSession ;
28
24
import org .junit .BeforeClass ;
29
25
import org .junit .Test ;
30
26
27
+ import java .io .Reader ;
28
+ import java .sql .Connection ;
29
+ import java .util .List ;
30
+ import java .util .Map ;
31
+
31
32
public class CallSettersOnNullsTest {
32
33
33
34
private static SqlSessionFactory sqlSessionFactory ;
@@ -86,4 +87,19 @@ public void shouldCallNullOnMap() {
86
87
}
87
88
}
88
89
90
+ @ Test
91
+ public void shouldCallNullOnMapForSingleColumn () {
92
+ SqlSession sqlSession = sqlSessionFactory .openSession ();
93
+ try {
94
+ Mapper mapper = sqlSession .getMapper (Mapper .class );
95
+ List <Map <String ,Object >> oneColumns = mapper .getNameOnly ();
96
+ for ( Map <String ,Object > onecol : oneColumns )
97
+ {
98
+ Assert .assertTrue ( onecol .containsKey ( "NAME" ) );
99
+ }
100
+ } finally {
101
+ sqlSession .close ();
102
+ }
103
+ }
104
+
89
105
}
Original file line number Diff line number Diff line change 16
16
17
17
drop table users if exists;
18
18
19
+ drop table users2 if exists;
20
+
19
21
create table users (
20
22
id int ,
21
23
name varchar (20 )
22
24
);
23
25
26
+ create table users2 (
27
+ id int ,
28
+ name varchar (20 )
29
+ )
30
+
24
31
insert into users (id, name) values (1 , NULL );
32
+
33
+ insert into users2 (id, name) values ( 2 , ' mary' );
34
+ insert into users2 (id, name) values ( 3 , ' angel' );
35
+ insert into users2 (id, name) values ( 1 , NULL );
36
+
37
+
Original file line number Diff line number Diff line change 15
15
*/
16
16
package org .apache .ibatis .submitted .call_setters_on_nulls ;
17
17
18
+ import java .util .List ;
18
19
import java .util .Map ;
19
20
20
21
public interface Mapper {
21
22
22
23
User getUserMapped (Integer id );
23
24
User getUserUnmapped (Integer id );
24
25
Map getUserInMap (Integer id );
26
+ List <Map <String ,Object >> getNameOnly ();
25
27
26
28
}
Original file line number Diff line number Diff line change 37
37
<result property =" name" column =" name" />
38
38
</resultMap >
39
39
40
+ <select id =" getNameOnly" resultType =" map" >
41
+ select name from users2
42
+ </select >
43
+
40
44
</mapper >
You can’t perform that action at this time.
0 commit comments