I’m using Mongo Java Driver 3.12 and have configured AutomaticPojoCodec. I’m writing a query which requests selected fields using Projections.include
but while deserialization I get error Could not construct new instance of: CaseDocument. Missing the following properties: [owner, requester, resolver, resolveByTime, creationTime, issue]
.
@Builder
@Data
@FieldDefaults(makeFinal = true)
class CaseDocument {
@BsonId
private long caseId;
private long creationTime;
private long resolveByTime;
private CaseOwner owner;
private CaseCustomer customer;
private CaseIssue issue;
private CaseRequester requester;
private CaseResolver resolver;
@BsonCreater
public CaseDocument() {
// All Args Constructor
}
}
In my query, I’m only requesting customer
property using Projections.include(Arrays.asList("customer"))
. I’ve verified that data is present in DB and is not null. Why MongoDB is not able to deserialize in this scenario?