Inserting Java Object to MongoDB Collection Using Java

I’m a little confused as to know why you’d think this would work in the first place. The first thing you need to know is how to map your POJO to a MongoDB document. Currently, you’re not telling the system(your code) how to do that.

You can either use a mapping library for this (Morphia comes to mind) or use ReflectionDBObject. Either solution allows you to map POJO to MongoDB document or MongoDB document to POJO(the former way is a lot more nicely than the latter).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)