I insert a document into a collection with a field of byte[]. When I query the inserted document to get that field, it returns a different byte[]. How do I fix that?
byte[] inputBytes = ... MongoCollection<Document> collection = _db.getCollection("collectionx"); Document doc = new Document("test", 1).append("val", inputBytes); collection.insertOne(doc.getDocument()); MongoCursor<Document> result = collection.find(eq("test", 1)).iterator(); Document retrived_doc = cursor.next(); cursor.close(); byte[] outputBytes = ((Binary)retrived_doc.get("val")).getData(); // inputBytes = [B@719f369d // outputBytes = [B@7b70cec2
toString()-results of input and output arrays. These just reflect their addresses in memory, not their contents. Why do you think these addresses should be identical?