@Override public Key<E> saveAndIndex(E entity) { Key<E> save = super.save(entity); String collection = entityManager.getCollection(clazz); if (collection != null) { commonService.indexEntity(ds, save.getKind(), save.getId().toString(), entity); } return save; }
public DBRef keyToRef(Key key) { if (key == null) return null; if (key.getKindClass() == null && key.getKind() == null) throw new IllegalStateException("How can it be missing both?"); if (key.getKind() == null) key.setKind(getCollectionName(key.getKindClass())); return new DBRef(null, key.getKind(), toMongoObject(key.getId(), false)); }
@Override public Key<E> saveAndIndex(final E entity) { final Key<E> save = super.save(entity); final String collection = entityManager.getCollection(clazz); if (collection != null) { commonService.indexEntity(ds, save.getKind(), save.getId().toString(), entity); } return save; } }
mapr.updateKind(key); if (clazzKind != null && !key.getKind().equals(clazzKind)) throw new IllegalArgumentException("Types are not equal (" + clazz + "!=" + key.getKindClass() + ") for key and method parameter clazz"); if (kindMap.containsKey(key.getKind())) kindMap.get(key.getKind()).add(key); else kindMap.put(key.getKind(), new ArrayList<Key>(Collections.singletonList((Key) key)));
/** * @param key * @param ops * @param <T> * @return */ 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); }
/** * @param entityOrKey * @return */ public Key<?> exists(Object entityOrKey) { entityOrKey = ProxyHelper.unwrap(entityOrKey); Key<?> key = mapr.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(); }