I am using a queryBuilder with a where to do a select. It’s a table of POJOs and in general has been working well for many users for a long period of time.
ArrayList<X> result = new ArrayList<X>();
QueryBuilder<X, Integer> queryBuilder = getXDao().queryBuilder();
Where<X, Integer> where = queryBuilder.where();
where.eq(X, x);
queryBuilder.orderBy(X, true);
result = (ArrayList<X>)getXDao().query(queryBuilder.prepare());
There is one particular who crashes every time they query this table due to the following ORMLite exception:
java.lang.IllegalStateException: Couldn't read row 1060, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetLong(CursorWindow.java)
at android.database.CursorWindow.getLong(CursorWindow.java:512)
at android.database.CursorWindow.getInt(CursorWindow.java:579)
at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:69)
at com.j256.ormlite.android.AndroidDatabaseResults.getInt(AndroidDatabaseResults.java:169)
at com.j256.ormlite.field.types.IntegerObjectType.resultToSqlArg(IntegerObjectType.java:37)
at com.j256.ormlite.field.BaseFieldConverter.resultToJava(BaseFieldConverter.java:24)
at com.j256.ormlite.field.FieldType.resultToJava(FieldType.java:799)
at com.j256.ormlite.stmt.mapped.BaseMappedQuery.mapRow(BaseMappedQuery.java:60)
at com.j256.ormlite.stmt.SelectIterator.getCurrent(SelectIterator.java:270)
at com.j256.ormlite.stmt.SelectIterator.nextThrow(SelectIterator.java:161)
at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:199)
at com.j256.ormlite.dao.BaseDaoImpl.query(BaseDaoImpl.java:263)
at com.j256.ormlite.dao.RuntimeExceptionDao.query(RuntimeExceptionDao.java:213)
I have seen it stated in the documentation that for medium or large sized tables it might be better to use an iterator. My question is if this number or rows would be considered ‘medium or large’. I would have thought not. Also I created tables larger than this without seeing this issue
Does anybody have a suggestion of what could be causing this or seen something similar before? Bad data possibly?