I am performing a simple delete of a ormlite object. The code is below. But no matter what, the object never get deleted.
Dao<Subscription, Object> dao = helper.getSubscriptionDataDao(); dao = helper.getSubscriptionDataDao(); QueryBuilder<Subscription, Object> query = dao.queryBuilder(); query.where().eq("key", subKey); Subscription sub = dao.queryForFirst(query.prepare()); int r = dao.delete(sub); // r is 1
Am I missing anything here?
This is how I solve the problem: Make sure the object have primary key. Setting the field as ID does not mean the ID will be auto generated. Without the ID, delete will fail.