} else {
if(entityForSave != null && id != null) {
log.info("Find document with id: " + id + " in collection with name: " + ((IEntity) entityForSave).getClass().getName());
Query<? extends IEntity> query = getDatastore().createQuery(((IEntity) entityForSave).getClass());
query = query.field("id").equal(id);
IEntity entity = (IEntity) query.get();
if(entity == null) {
log.info("Can not find document in collection: " + ((IEntity) entityForSave).getClass().getName());
return null;
} else {
log.info("We found document with id: " + id + " in collection: " + entity.getClass().getName());
return entity;
}
}
}
return null;