我正在尝试在JSON上实现findOne
查询:
我的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;
}
任何人都知道我缺少什么?
答案 0 :(得分:0)
代码有效,frontEnd包含提交错误字段名称的错误。