[英]Raw Query is unable to convert BLOB to string for selecting column of String[]
我遇到一個出現此錯誤的問題:
Caused by: android.database.sqlite.SQLiteException: unknown error (code 0): Unable to convert BLOB to string
我在這段代碼中遇到了這個問題:
GenericRawResults<String[]> rawResults;
rawResults = DatabaseHelper.getHelper(this)
.getDaoForClass(Table1.class)
.queryRaw("SELECT idList, COUNT(*) FROM Table1 ORDER BY idList");
List<String[]> results = rawResults.getResults();
當我嘗試將rawResult轉換為結果時。 “ idList”字段為String []
我也嘗試使用此查詢選擇列:
SELECT idList FROM Table1
但是出現了同樣的錯誤。
基本上我想做的是選擇id包含在idList字段String []中的對象的頻率。
根據要求,我從中選擇的表是這樣的:
@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包含您要查看計數的ID,然后查詢應該像
SELECT ID, COUNT(*)
FROM Table1
WHERE ID in (XXX)
GROUP BY ID
ORDER BY ID
XXX-應該是將idList轉換為包含以ID分隔的ID的字符串,例如。 1,2,3,4,5或'1','2','3'(如果ID為字符串)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.