Greendao DaoException Object does not have a key

Using GreenDao, I somehow deleted my db to a state where I have an object that does not have a key.

My questions: how to delete / delete this object? I have not seen a function in AbstractDao that will allow me to delete another column name.

+4
source share
2 answers

You can write a raw SQL query to delete a row and execute it using SQLiteDatabase, which you can get from your readable DaoSession.

DELETE FROM YourTable WHERE someColumn=?

If you want to avoid typos, you can use the tableinformation from greendao:

String query = "DELETE FROM " + YourDao.TABLENAME +
               " WHERE " + YourDao.Properties.SomeColumn.columnName + "=?";

For more information:

Depending on how you created your scheme, there are some pitfalls:

AUTOINCREMENT NOT NULL, greendao !

, 0, .

notNull().primaryKey().autoincrement(), greendao-sourcecode.

greendao-core, , , primaryKey().autoincrement().

0

, , ( null(). primaryKey()), . , greenDAO. - greenDAO .

, .

0

All Articles