Trying to read a document into a complex POJO , getting null for Id Object

Hello
I am trying to read a document into a complex POJO

Ex

public class UserRecommendations {

    @BsonId
    @BsonProperty("id")
    private UserRecoIdObject id;
    private String jobId;
    private List<Integer> recommendations;
public UserRecommendations(UserRecoIdObject id, String jobId, List<Integer> recommendations) {
        this.id = id;
        this.jobId = jobId;
        this.recommendations = recommendations;
    }

    public UserRecommendations() {
    }

}
public class UserRecoIdObject {
    private String partnerId;
    private String userId; 
}

However the id is being read as null

[UserRecommendations{_id=null, jobId=‘809871fc-f83c-4270-82bf-0dc39aafe446’, recommendations=[7, 2, 0, 6, 1, 5, 9, 4, 3, 8]}, UserRecommendations{_id=null, jobId=‘9f4db498-f9df-449f-8768-15c1d9f2dd5b’, recommendations=[7, 2, 0, 6, 1, 5, 9, 4, 3, 8]}]

Appreciate any suggestions to resolve this

Hi @Mrinal_Thigale and welcome to the community. :wave:

From the above error it seems like the UserRecoIdObject is not performing the correct mapping between POJO class and the BSON document. To begin with, you might want to read the article for Java-Mapping POJOs for starters.

If you are still facing the issue, can you provide a sample BSON document that you’re trying to read into the POJO class?

Regards
Aasawari