ORMLite IllegalStateException when there are many records

旧巷老猫 提交于 2019-12-24 13:35:12

问题


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?

来源:https://stackoverflow.com/questions/27174572/ormlite-illegalstateexception-when-there-are-many-records

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!