예제 #1
0
  public <T> UpdateResults<T> update(T ent, UpdateOperations<T> ops) {
    MappedClass mc = mapr.getMappedClass(ent);
    Query<T> q = (Query<T>) createQuery(mc.getClazz());
    q.disableValidation().filter(Mapper.ID_KEY, getId(ent));

    if (mc.getFieldsAnnotatedWith(Version.class).size() > 0) {
      MappedField versionMF = mc.getFieldsAnnotatedWith(Version.class).get(0);
      Long oldVer = (Long) versionMF.getFieldValue(ent);
      q.filter(versionMF.getNameToStore(), oldVer);
      ops.set(versionMF.getNameToStore(), VersionHelper.nextValue(oldVer));
    }

    return update(q, ops);
  }
예제 #2
0
 @SuppressWarnings("rawtypes")
 private <T> UpdateResults<T> update(
     Query<T> query,
     UpdateOperations ops,
     boolean createIfMissing,
     boolean multi,
     WriteConcern wc) {
   DBObject u = ((UpdateOpsImpl) ops).getOps();
   if (((UpdateOpsImpl) ops).isIsolated()) {
     Query<T> q = query.clone();
     q.disableValidation().filter("$atomic", true);
     return update(q, u, createIfMissing, multi, wc);
   }
   return update(query, u, createIfMissing, multi, wc);
 }