I am trying to create a android app using GreenDAO, this is ERP kind of project so practically it is not possible to post all code here, but i am going to share only related code
QueryBuilder<PartyCommunication> partyCommQueryBuilder = partyCommunicationDao.queryBuilder();
partyCommQueryBuilder = partyCommQueryBuilder.where(
PartyCommunicationDao.Properties.CommType.eq("ALERT"),
PartyCommunicationDao.Properties.ReferenceCategory.eq("Low Stock"));
List<PartyCommunication> listOfPartyComm = partyCommQueryBuilder.list();
PartyCommunication daoPartyCommunication = listItr.next();
Long reference_entity_key = daoPartyCommunication.getReferenceEntityKey();
Product product = daoSessionUni.getProductDao().load(reference_entity_key);
ProductDetail productDetail = new ProductDetail(product);
Integer inventoryQOH= productDetail.getInventoryQOH();
I am getting exception in this line
Product product = daoSessionUni.getProductDao().load(reference_entity_key);
When i debug our application i found that it throwing exception from one of our DAO class as below
public Product readEntity(Cursor cursor, int offset) {
Product entity = new Product( //
.
.
.
.
cursor.getShort(offset + 23) != 0, // isSync
cursor.getShort(offset + 24) != 0, // isDeleted
cursor.getString(offset + 25), // createdBy
cursor.getString(offset + 26), // modifiedBy
cursor.isNull(offset + 27) ? null : new java.util.Date(cursor.getLong(offset + 27)), // lastSyncTime
new java.util.Date(cursor.getLong(offset + 28)), // created
new java.util.Date(cursor.getLong(offset + 29)) // modified
);
return entity;
}
In this line
cursor.getString(offset + 25), // createdBy
This is our 25th column of table.I know that all code is not enough to understand what is going wrong and why i am getting this exception , so i am also going to post logcat output
java.lang.IllegalStateException: get field slot from row 0 col 25 failed
at net.sqlcipher.CursorWindow.getString_native(Native Method)
at net.sqlcipher.CursorWindow.getString(CursorWindow.java:382)
at net.sqlcipher.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
at android.database.CursorWrapper.getString(CursorWrapper.java:114)
at com.tarnea.kareeb.model.ProductDao.readEntity(ProductDao.java:273)
at com.tarnea.kareeb.model.ProductDao.readEntity(ProductDao.java:1)
at de.greenrobot.dao.AbstractDao.loadCurrent(AbstractDao.java:417)
at de.greenrobot.dao.AbstractDao.loadUnique(AbstractDao.java:163)
at de.greenrobot.dao.AbstractDao.loadUniqueAndCloseCursor(AbstractDao.java:150)
at de.greenrobot.dao.AbstractDao.load(AbstractDao.java:139)
at com.tarnea.android.DataCleaningService.adjustLowStockAlertTable(DataCleaningService.java:115)
at com.tarnea.sync.kareeb.pharma.syncadapter.SyncManager.performSync(SyncManager.java:970)
at com.tarnea.sync.kareeb.pharma.syncadapter.SyncAdapter.onPerformSync(SyncAdapter.java:96)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:254
Thanks in advance to all.If anybody have some interest to solve my problem then please please ask any further information whatever you want.