コード例 #1
0
  @Override
  public Comment setComment(Comment c) {
    Query q = new Query();
    q.addCriteria(
        Criteria.where("idPath")
            .is(c.getIdPath())
            .andOperator(Criteria.where("deviceId").is(c.getDeviceId())));

    Update u = new Update();
    u.set("idPath", c.getIdPath());
    u.set("idTicket", c.getIdTicket());
    u.set("content", c.getContent());
    u.set("author", c.getAuthor());
    u.set("deviceId", c.getDeviceId());
    u.set("title", c.getTitle());
    u.set("rating", c.getRating());
    u.set("realdate", c.getRealdate());
    FindAndModifyOptions options = new FindAndModifyOptions();
    options.upsert(true);
    options.returnNew(true);
    return mongoOp.findAndModify(q, u, options, Comment.class);
  }