Skip to content

Commit

Permalink
Related to mybatis#61
Browse files Browse the repository at this point in the history
  • Loading branch information
emacarron committed Jul 16, 2013
1 parent 0b94647 commit 9f85c37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ public class CallSettersOnNullsTest {
@BeforeClass
public static void setUp() throws Exception {
// create a SqlSessionFactory
Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/call_setters_on_nulls/mybatis-config.xml");
Reader reader = Resources
.getResourceAsReader("org/apache/ibatis/submitted/call_setters_on_nulls/mybatis-config.xml");
sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
reader.close();

// populate in-memory database
SqlSession session = sqlSessionFactory.openSession();
Connection conn = session.getConnection();
reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/call_setters_on_nulls/CreateDB.sql");
reader = Resources
.getResourceAsReader("org/apache/ibatis/submitted/call_setters_on_nulls/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
Expand Down Expand Up @@ -87,19 +89,16 @@ public void shouldCallNullOnMap() {
}
}

@Test
public void shouldCallNullOnMapForSingleColumn() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
Mapper mapper = sqlSession.getMapper(Mapper.class);
List<Map<String,Object>> oneColumns = mapper.getNameOnly();
for( Map<String,Object> onecol: oneColumns )
{
Assert.assertTrue( onecol.containsKey( "NAME" ) );
}
} finally {
sqlSession.close();
}
@Test
public void shouldCallNullOnMapForSingleColumn() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
Mapper mapper = sqlSession.getMapper(Mapper.class);
List<Map<String, Object>> oneColumns = mapper.getNameOnly();
Assert.assertNull(oneColumns.get(1));
} finally {
sqlSession.close();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ create table users2(
insert into users (id, name) values(1, NULL);

insert into users2 (id, name) values( 2, 'mary' );
insert into users2 (id, name) values( 3, 'angel' );
insert into users2 (id, name) values( 1, NULL );


0 comments on commit 9f85c37

Please sign in to comment.