mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-12-21 23:08:52 -05:00
Fix generic array creation error in JdbcMapper, add test
This commit is contained in:
parent
1c561181ff
commit
c04a9ee842
@ -255,7 +255,9 @@ public class CompileTimeResultSetMapper {
|
||||
final String returnTypeString = componentTypeMirror.toString();
|
||||
writeCollection(w, keys, "java.util.List<" + returnTypeString + ">", "java.util.ArrayList", componentTypeMirror, maxRows, cal, cleaner, reflectionFields);
|
||||
w.write("\t\t\treturn _colret.toArray(new ");
|
||||
w.write(returnTypeString);
|
||||
// have to strip generics to avoid "generic array creation" compilation failure
|
||||
final int indexOfGeneric = returnTypeString.indexOf('<');
|
||||
w.write(indexOfGeneric < 0 ? returnTypeString : returnTypeString.substring(0, indexOfGeneric));
|
||||
w.write("[_colret.size()]);\n");
|
||||
}
|
||||
|
||||
|
@ -129,10 +129,8 @@ public interface QmDao extends JdbcMapper {
|
||||
@SQL(allNames)
|
||||
List<Map<String, String>> getAllNames() throws SQLException;
|
||||
|
||||
/*
|
||||
@SQL(allNames)
|
||||
Map[] getAllNamesArray() throws SQLException; // todo: try Map<String, String>[] fix 'generic array creation' error
|
||||
*/
|
||||
Map<String, String>[] getAllNamesArray() throws SQLException;
|
||||
|
||||
@SQL(allNames)
|
||||
Map<String, String> getAllNameMap() throws SQLException;
|
||||
|
@ -195,12 +195,10 @@ public class QueryMapperQmDao implements QmDao {
|
||||
return qm.toListMap(allNames, Map.class, String.class);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public Map<String, String>[] getAllNamesArray() throws SQLException {
|
||||
return qm.toArrayMap(allNames, Map.class, String.class);
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAllNameMap() throws SQLException {
|
||||
|
@ -285,14 +285,11 @@ public class QueryMapperTest {
|
||||
Assert.assertEquals(arrayMap, qm.getAllNames());
|
||||
}
|
||||
|
||||
/*
|
||||
// todo: fix jdbcmapper for this
|
||||
@Test
|
||||
public void testSelectArrayMap() throws Throwable {
|
||||
final List<Map<String, String>> arrayMap = getListMap();
|
||||
assertArrayEquals(arrayMap.toArray(new Map[arrayMap.size()]), qm.getAllNamesArray());
|
||||
}
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testSelectMapString() throws Throwable {
|
||||
|
Loading…
Reference in New Issue
Block a user