Ticket User Report

I am getting this error

org.bson.codecs.configuration.CodecConfigurationException: An exception occurred when decoding using the AutomaticPojoCodec.
Decoding into a ‘Comment’ failed with the following exception:

Failed to decode ‘Comment’. Decoding ‘_id’ errored with: readObjectId can only be called when CurrentBSONType is OBJECT_ID, not when CurrentBSONType is STRING.

A custom Codec or PojoCodec may need to be explicitly configured and registered to handle this type.

The pipeline code is this

    BsonField sum1 = Accumulators.sum("count", 1);
    // adding both group _id and accumulators
    Bson groupStage = Aggregates.group("$email", sum1);
    Bson sortStage = Aggregates.sort(Sorts.descending("count"));
    Bson limitStage = Aggregates.limit(20);
    List<Bson> pipeline = new ArrayList<>();

    List<Comment> results = new ArrayList<>();

I did check the thread here Ticket: User Report but it didn’t help

Resolved the issue by passing the pojo class in aggregate function

1 Like