fix storing food to the database

This commit is contained in:
Milos Kozak 2018-01-23 23:14:39 +01:00
parent 9663dd499e
commit b6f3fae487

View file

@ -70,7 +70,7 @@ public class FoodHelper {
public boolean createOrUpdate(Food food) { public boolean createOrUpdate(Food food) {
try { try {
// find by NS _id // find by NS _id
if (food._id != null) { if (food._id != null && !food._id.equals("")) {
Food old; Food old;
QueryBuilder<Food, Long> queryBuilder = getDaoFood().queryBuilder(); QueryBuilder<Food, Long> queryBuilder = getDaoFood().queryBuilder();
@ -90,12 +90,13 @@ public class FoodHelper {
} else { } else {
return false; return false;
} }
} else {
getDaoFood().createOrUpdate(food);
log.debug("FOOD: New record: " + food.toString());
scheduleFoodChange();
return true;
} }
} }
getDaoFood().createOrUpdate(food);
log.debug("FOOD: New record: " + food.toString());
scheduleFoodChange();
return true;
} catch (SQLException e) { } catch (SQLException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }