I can't retrieve the address fields from my embedded document. I haven't seen any solutions for the 3.4 MongoDB driver.
System.out.println("Selecting Person ");
MongoCollection<Document> collection = mdb.getCollection("Person");
MongoCursor<Document> cursor = collection.find().iterator();
try {
while (cursor.hasNext()) {
Document temp_person_doc=cursor.next();
Document temp_address_doc=temp_person_doc.get("address");
String houseNo=temp_address_doc.getString("houseNo");
}
} finally {
cursor.close();
}
Here is the document structure.
{
"_id" : "5aae9920982f271ba4b08735",
"firstName" : "homer",
"surname" : "simpson",
"address" : {
"houseNo" : 742,
"address" : "evergreen terrace",
"city" : "springfield",
}
}