简体   繁体   中英

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. "idList" field is 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[].

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

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. 1,2,3,4,5 or '1','2','3' if the id is string

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM