Mapping of List of Documents of type org.bson.Document to java.util.List of POJOs

414 views
Skip to first unread message

Kiran Kumar

unread,
Mar 23, 2016, 7:21:44 AM3/23/16
to mongodb-user

Hi,

We have employee Documents in MongoDB (Please see below for the sample) and we retrieve these documents in a list of org.bson.Document objects by using MongoDB Java Driver 3.0.4 . We need to map this list of org.bson.Document objects to list of plain old java objects of type Employee. Please let me know if there is any API or library from MongoDB for doing the same.

{
"_id":ObjectId("231be1ae4e51b95"),
"employeeId":"312000",
"employeeName":"Peter",
"employeeSal":21000.43,
"creationDate":ISODate("2015-11-30T05:38:48.000+0000"),
lastUpdateDate:ISODate("2015-11-30T05:38:48.000+0000"),
"employAddress":[

{"pinCode":1000.00, "address":"Kings Road"}

{"pinCode":2000.00, "address":"George Street" }

]
}

Ankur Raina

unread,
Apr 15, 2016, 12:10:22 AM4/15/16
to mongodb-user

Hi Kiran,

There are several third party libraries available to help you implement this. I would suggest taking a look on the Third Party Frameworks and Libraries:POJO Mappers in MongoDB java driver docs.

Regards
Ankur

Reply all
Reply to author
Forward
0 new messages