return save(model, true);
}
private T save(T model, boolean audit) {
getQueryCache().removeQueries(clazz);
Entity entity = null;
if (model.getId() != null) {
try {
getDao().getDaoStat().incGetCalls();
entity = getDatastore().get(getKey(model.getId()));
getEntityCache().removeEntity(clazz, model.getId());
}
catch (EntityNotFoundException e) {
logger.error("Entity not found " + clazz.getName() + " "
+ model.getId());
}
}
if (entity == null) {
entity = new Entity(getKind());
model.setCreateUserEmail(getCurrentUserEmail());
}
if (audit) {
model.setModDate(new Date());
model.setModUserEmail(getCurrentUserEmail());
}
model.save(entity);
getDatastore().put(entity);
model.setKey(entity.getKey());
return model;
}