0

我正在尝试findOne对 JSON 进行查询:

我的 JSON 看起来像这样:

{
  "_id":{
    "$oid":"5613b8d360b292805a5d7f2d"
  },
  "resellerId":"1"
....
}

这是我的Java代码:

final JacksonDBCollection<MongoDocument, String> resellerWidget = 
    JacksonDBCollection.wrap(mongoDB.getCollection("resellerWidget"),         
    MongoDocument.class, String.class);

MongoDocument md = 
    resellerWidget.findOne(DBQuery.and(DBQuery.is("_id",widgetId),
    (DBQuery.is("resellerId", resellerId))));

但它没有找到记录。不过,当我只查询 widgetId 时,我确实找到了它。

MongoDocument的相关部分:

@JsonIgnoreProperties(ignoreUnknown = true)
public class MongoDocument {

    private String id;
        private String resellerId;
    private final Map<String, JsonNode> extraProperties = new HashMap<>();

    @ObjectId
    @JsonProperty("_id")
    public String getId() {
        return this.id;
    }

    @ObjectId
    @JsonProperty("_id")
    public void setId(String id) {
        this.id = id;
    }


    @JsonProperty("resellerId")
    public String getResellerId() {
        return this.resellerId;
    }

    @JsonProperty("resellerId")
    public void setResellerId(String id) {
        this.resellerId = id;
    }

有人知道我错过了什么吗?

4

1 回答 1

0

代码有效,前端包含提交错误字段名称的错误。

于 2016-01-07T10:17:20.083 回答