Skip to content

Commit 6874d07

Browse files
committed
To simplify keyProperty referencing rule, drop the code for backward compatibility.
1 parent 1845f0b commit 6874d07

File tree

2 files changed

+0
-75
lines changed

2 files changed

+0
-75
lines changed

src/main/java/org/apache/ibatis/executor/keygen/Jdbc3KeyGenerator.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.sql.Statement;
2222
import java.util.Arrays;
2323
import java.util.Collection;
24-
import java.util.List;
2524
import java.util.Map;
2625

2726
import org.apache.ibatis.binding.BindingException;
@@ -92,26 +91,6 @@ public void processBatch(MappedStatement ms, Statement stmt, Object parameter) {
9291

9392
protected void assignKeysToOneOfParams(final Configuration configuration, ResultSet rs, final String[] keyProperties,
9493
Map<?, ?> paramMap) throws SQLException {
95-
// For backward compatibility, search parameter with special name first.
96-
if (paramMap.containsKey("collection")) {
97-
Object param = paramMap.get("collection");
98-
if (param instanceof Collection) {
99-
assignKeysToParam(configuration, rs, keyProperties, param);
100-
return;
101-
}
102-
} else if (paramMap.containsKey("list")) {
103-
Object param = paramMap.get("list");
104-
if (param instanceof List) {
105-
assignKeysToParam(configuration, rs, keyProperties, param);
106-
return;
107-
}
108-
} else if (paramMap.containsKey("array")) {
109-
Object param = paramMap.get("array");
110-
if (param instanceof Object[]) {
111-
assignKeysToParam(configuration, rs, keyProperties, param);
112-
return;
113-
}
114-
}
11594
// Assuming 'keyProperty' includes the parameter name. e.g. 'param.id'.
11695
int firstDot = keyProperties[0].indexOf('.');
11796
if (firstDot == -1) {

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

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -251,60 +251,6 @@ public void shouldFailIfKeyPropertyIsInvalid_WrongParamName() throws Exception {
251251
}
252252
}
253253

254-
@Test
255-
public void shouldAssignKeysToList_MultiParams() throws Exception {
256-
SqlSession sqlSession = sqlSessionFactory.openSession();
257-
try {
258-
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
259-
List<Country> countries = new ArrayList<Country>();
260-
countries.add(new Country("China", "CN"));
261-
countries.add(new Country("United Kiongdom", "GB"));
262-
mapper.insertListAndSomeId(countries, Integer.valueOf(1));
263-
for (Country country : countries) {
264-
assertNotNull(country.getId());
265-
}
266-
} finally {
267-
sqlSession.rollback();
268-
sqlSession.close();
269-
}
270-
}
271-
272-
@Test
273-
public void shouldAssignKeysToCollection_MultiParams() throws Exception {
274-
SqlSession sqlSession = sqlSessionFactory.openSession();
275-
try {
276-
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
277-
Set<Country> countries = new HashSet<Country>();
278-
countries.add(new Country("China", "CN"));
279-
countries.add(new Country("United Kiongdom", "GB"));
280-
mapper.insertSetAndSomeId(countries, Integer.valueOf(1));
281-
for (Country country : countries) {
282-
assertNotNull(country.getId());
283-
}
284-
} finally {
285-
sqlSession.rollback();
286-
sqlSession.close();
287-
}
288-
}
289-
290-
@Test
291-
public void shouldAssignKeysToArray_MultiParams() throws Exception {
292-
SqlSession sqlSession = sqlSessionFactory.openSession();
293-
try {
294-
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
295-
Country[] countries = new Country[2];
296-
countries[0] = new Country("China", "CN");
297-
countries[1] = new Country("United Kiongdom", "GB");
298-
mapper.insertArrayAndSomeId(countries, Integer.valueOf(1));
299-
for (Country country : countries) {
300-
assertNotNull(country.getId());
301-
}
302-
} finally {
303-
sqlSession.rollback();
304-
sqlSession.close();
305-
}
306-
}
307-
308254
@Test
309255
public void shouldAssignKeysToNamedList_MultiParams() throws Exception {
310256
SqlSession sqlSession = sqlSessionFactory.openSession();

0 commit comments

Comments
 (0)