I have a Java object that looks like this:
public class Partner {
private String partnerName;
private String partnerRef;
private Site sites;
I have this stored in MongoDB as a document. I am attempting to retrieve it like this:
public List<Partner> getAllPartners(
MongoCollection<Partner> partnerCollection) {
List<Partner> partnerList = new ArrayList<>();
return partnerCollection.find().into(partnerList);
}
I keep receiving the below error:
"message": "An exception occurred when decoding using the AutomaticPojoCodec.\nDecoding into a 'Partner' failed with the following exception:\n\nFailed to decode 'Partner'. Decoding 'sites' errored with: readStartDocument can only be called when CurrentBSONType is DOCUMENT, not when CurrentBSONType is ARRAY.\n\nA custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type.",
I assume this is occurring because of the Site object within the Partner Object, but I cannot for the life of me figure out how to fix this problem.