public <T> UpdateResults<T> updateFirst(Query<T> query, T entity, boolean createIfMissing) {
LinkedHashMap<Object, DBObject> involvedObjects = new LinkedHashMap<Object, DBObject>();
DBObject dbObj = mapr.toDBObject(entity, involvedObjects);
UpdateResults<T> res = update(query, dbObj, createIfMissing, false, getWriteConcern(entity));
CommandResult gle = res.getWriteResult().getCachedLastError();
if (gle != null && res.getInsertedCount() > 0)
dbObj.put(Mapper.ID_KEY, res.getNewId());
postSaveOperations(entity, dbObj, involvedObjects);
return res;
}