Skip to content

Commit 5e9d5a2

Browse files
committed
Added another test for Jdbc3KeyGenerator
#1600 (comment)
1 parent a262898 commit 5e9d5a2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/test/java/org/apache/ibatis/submitted/keygen/CountryMapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,8 @@ int insertMultiParams_keyPropertyWithWrongParamName(@Param("country") Country co
108108
@Options(useGeneratedKeys = true, keyProperty = ParamNameResolver.GENERIC_NAME_PREFIX + "2.id")
109109
@Insert({ "insert into country (countryname,countrycode) values (#{param2.countryname},#{param2.countrycode})" })
110110
int singleParamWithATrickyName(@Param(ParamNameResolver.GENERIC_NAME_PREFIX + "2") Country country);
111+
112+
@Options(useGeneratedKeys = true, keyProperty = "id")
113+
@Insert({ "insert into country (countryname,countrycode) values (#{countryname},#{countrycode})" })
114+
int insertMap(Map<String, Object> map);
111115
}

src/test/java/org/apache/ibatis/submitted/keygen/Jdbc3KeyGeneratorTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,4 +590,20 @@ void shouldAssignKeyToAParamWithTrickyName() {
590590
}
591591
}
592592
}
593+
594+
@Test
595+
void shouldAssingKeysToAMap() {
596+
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
597+
try {
598+
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
599+
Map<String, Object> map = new HashMap<>();
600+
map.put("countrycode", "CN");
601+
map.put("countryname", "China");
602+
mapper.insertMap(map);
603+
assertNotNull(map.get("id"));
604+
} finally {
605+
sqlSession.rollback();
606+
}
607+
}
608+
}
593609
}

0 commit comments

Comments
 (0)