0

I am trying to implement a findOne query on JSON:

My JSON looks like this:

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

And here is my Java code:

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))));

But it does not find a record. When I only query for widgetId though, I do find it.

Relevant part of 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;
    }

Anyone any idea what I'm missing?

CubeJockey
  • 2,209
  • 8
  • 24
  • 31

1 Answers1

0

Code works, frontEnd contained a bug submitting wrong field name.