public Key<?> exists(Object entityOrKey) { entityOrKey = ProxyHelper.unwrap(entityOrKey); Key<?> key = getKey(entityOrKey); Object id = key.getId(); if (id == null) throw new MappingException("Could not get id for " + entityOrKey.getClass().getName()); String collName = key.getKind(); if (collName == null) collName = getCollection(key.getKindClass()).getName(); return find(collName, key.getKindClass()).filter(Mapper.ID_KEY, key.getId()).getKey(); }
public <T> UpdateResults<T> update(Key<T> key, UpdateOperations<T> ops) { Class<T> clazz = (Class<T>) key.getKindClass(); if (clazz == null) clazz = (Class<T>) mapr.getClassFromKind(key.getKind()); return updateFirst( createQuery(clazz).disableValidation().filter(Mapper.ID_KEY, key.getId()), ops); }