mirror of
https://github.com/moparisthebest/JdbcMapper
synced 2024-11-25 18:32:18 -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();
|
final String returnTypeString = componentTypeMirror.toString();
|
||||||
writeCollection(w, keys, "java.util.List<" + returnTypeString + ">", "java.util.ArrayList", componentTypeMirror, maxRows, cal, cleaner, reflectionFields);
|
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("\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");
|
w.write("[_colret.size()]);\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,10 +129,8 @@ public interface QmDao extends JdbcMapper {
|
|||||||
@SQL(allNames)
|
@SQL(allNames)
|
||||||
List<Map<String, String>> getAllNames() throws SQLException;
|
List<Map<String, String>> getAllNames() throws SQLException;
|
||||||
|
|
||||||
/*
|
|
||||||
@SQL(allNames)
|
@SQL(allNames)
|
||||||
Map[] getAllNamesArray() throws SQLException; // todo: try Map<String, String>[] fix 'generic array creation' error
|
Map<String, String>[] getAllNamesArray() throws SQLException;
|
||||||
*/
|
|
||||||
|
|
||||||
@SQL(allNames)
|
@SQL(allNames)
|
||||||
Map<String, String> getAllNameMap() throws SQLException;
|
Map<String, String> getAllNameMap() throws SQLException;
|
||||||
|
@ -195,12 +195,10 @@ public class QueryMapperQmDao implements QmDao {
|
|||||||
return qm.toListMap(allNames, Map.class, String.class);
|
return qm.toListMap(allNames, Map.class, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String>[] getAllNamesArray() throws SQLException {
|
public Map<String, String>[] getAllNamesArray() throws SQLException {
|
||||||
return qm.toArrayMap(allNames, Map.class, String.class);
|
return qm.toArrayMap(allNames, Map.class, String.class);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getAllNameMap() throws SQLException {
|
public Map<String, String> getAllNameMap() throws SQLException {
|
||||||
|
@ -285,14 +285,11 @@ public class QueryMapperTest {
|
|||||||
Assert.assertEquals(arrayMap, qm.getAllNames());
|
Assert.assertEquals(arrayMap, qm.getAllNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// todo: fix jdbcmapper for this
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelectArrayMap() throws Throwable {
|
public void testSelectArrayMap() throws Throwable {
|
||||||
final List<Map<String, String>> arrayMap = getListMap();
|
final List<Map<String, String>> arrayMap = getListMap();
|
||||||
assertArrayEquals(arrayMap.toArray(new Map[arrayMap.size()]), qm.getAllNamesArray());
|
assertArrayEquals(arrayMap.toArray(new Map[arrayMap.size()]), qm.getAllNamesArray());
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelectMapString() throws Throwable {
|
public void testSelectMapString() throws Throwable {
|
||||||
|
Loading…
Reference in New Issue
Block a user