[英]Raw Query is unable to convert BLOB to string for selecting column of String[]
I have an issue where I'm getting this error: 我遇到一个出现此错误的问题:
Caused by: android.database.sqlite.SQLiteException: unknown error (code 0): Unable to convert BLOB to string
I'm getting this issue with this piece of code: 我在这段代码中遇到了这个问题:
GenericRawResults<String[]> rawResults;
rawResults = DatabaseHelper.getHelper(this)
.getDaoForClass(Table1.class)
.queryRaw("SELECT idList, COUNT(*) FROM Table1 ORDER BY idList");
List<String[]> results = rawResults.getResults();
when I'm trying to convert rawResult to results. 当我尝试将rawResult转换为结果时。 "idList" field is String[] “ idList”字段为String []
I also tried to just select column with this query: 我也尝试使用此查询选择列:
SELECT idList FROM Table1
But same error appeared. 但是出现了同样的错误。
Basically what I'm trying to do is to select frequency of objects which id's are contained inside idList field String[]. 基本上我想做的是选择id包含在idList字段String []中的对象的频率。
As requested, table from which I'm selecting is this: 根据要求,我从中选择的表是这样的:
@DatabaseField(canBeNull = false, columnName = "type")
@Expose
@SerializedName("type")
public Type type;
@DatabaseField(columnName = "idList", dataType = DataType.SERIALIZABLE)
@Expose
@SerializedName("idList")
public String[] idList;
@DatabaseField(canBeNull = false, columnName = "occurredDate")
@Expose
@SerializedName("occurredDate")
public Date occurredDate;
Ii idList contains ids you want to see the count then maybe the query should be like ii idList包含您要查看计数的ID,然后查询应该像
SELECT ID, COUNT(*)
FROM Table1
WHERE ID in (XXX)
GROUP BY ID
ORDER BY ID
XXX - should be the idList converted to string containing ids separated with , eg. XXX-应该是将idList转换为包含以ID分隔的ID的字符串,例如。 1,2,3,4,5 or '1','2','3' if the id is string 1,2,3,4,5或'1','2','3'(如果ID为字符串)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.