I have a few entries in a mongodb database. They have binary _ids. If I query with a mongo client like robomongo I'm able to find the entry I'm looking for:
db.getCollection('comment').find({"_id" : new BinData(0,"nCgNlWhzJM9/lHDVQmXQrg==")})
However, I'm having serious issues with doing the same in java. Here is what I'm trying to do:
final MongoCollection<Document> mongoCollection = mongoDatabase.getCollection("comment");
mongoCollection
.find(eq("_id", new Binary((byte) 0, "nCgNlWhzJM9/lHDVQmXQrg==".getBytes(StandardCharsets.UTF_8))))
.first()
Sadly this is not working. Trying to find an item with a string type works (like eq("author", "someone) ).