I’m trying to group documents based on conditionGroupControlId, conditionGroupScac, conditionGroupId and then selecting the document having the highest conditionGroupRevisionId. Then putting the result in conditionGroups which is list of POJO PrismConditionGroup.
priceAggregate.add(new Document("$group", new Document("_id", new Document("conditionGroupControlId", "$conditionGroupControlId") .append("conditionGroupScac", "$conditionGroupScac") .append("conditionGroupId", "$conditionGroupId")) .append("conditionGroupRevisionId", new Document("$max", "$conditionGroupRevisionId")))); conditionGroupCollection.aggregate(priceAggregate).forEach(conditionGroups::add);
PrismConditionGroup extends another class containing below field:
@BsonProperty("_id") @BsonId private ObjectId id;
Below is the error I’m getting:
[INFO] Decoding into a ‘PrismConditionGroup’ failed with the following exception:
[INFO] Failed to decode ‘PrismConditionGroup’. Decoding ‘_id’ errored with: readObjectId can only be called when CurrentBSONType is OBJECT_ID, not when CurrentBSONType is DOCUMENT.
[INFO] A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type.
Can someone please suggest me how to solve this issue?