I'm trying to use this SQL command with Ormlite:
select address from receive
With this code:
List<Receivers> receiver_address = receiverDao.queryBuilder().selectColumns("address").query();
But the object returned is:
1 = {Receivers@830028192208}
address = {String@830028192264} "my new address"
city = null
email = null
telephone = null
mobile = null
name_family = null
national_code = null
postal_code = null
receiver_name = null
id = 2
I need only address
field in this query without iterator
such as:
List<String> list = new ArrayList<String>();
for( Receivers lst:receiver_address)
list.add(lst.getAddress());
How to do this action?
答案 0 :(得分:6)
您可以在此处使用RawRowMapper:
List<String> addresses = receiverDao.queryRaw("select address from receive", new RawRowMapper<String>() {
@Override
public String mapRow(String[] columnNames, String[] resultColumns) throws SQLException {
return resultColumns[0];
}
}).getResults();