0

我正在尝试在android上使用ormlite将整个列值转换为arrayList,这可能吗,直接api?使用原始结果我很接近,但不完全是:

GenericRawResults<String[]> rawResults =
     getHelper().getMyProcessDao().queryRaw(
         queryBuild.selectColumns("nid").prepareStatementString());
List<String[]> result = rawResults.getResults();
4

1 回答 1

4

人力资源管理系统。我不确定这是你想要的。但是,完成您具体要求的一种方法是通过使用RawRowMapper可以传递给ORMLite 的DAO 方法的方法:dao.queryRaw(String, Rowmapper, String...)

像下面这样的东西应该可以工作:

RawRowMapper<Integer> mapper = new RawRowMapper<Integer>() {
     public Integer mapRow(String[] columnNames, String[] resultColumns) {
        // maybe you should verify that there _is_ only 1 column here
        // maybe you should handle the possibility of a bad number and throw
        return Integer.parseInt(resultColumns[0]);
     }
};
GenericRawResults<Integer> rawResults =
    getHelper().getMyProcessDao().queryRaw(
        queryBuild.selectColumns("nid").prepareStatementString(), mapper);
List<Integer> list = rawResults.getResults();
于 2012-07-11T17:45:12.960 回答