2

I'm using allanbank async driver for operations on mongodb. Is there any api available through which I can convert returned Document to a POJO, like we can do in spring driver available for mongodb

Sumit Dhaniya
  • 596
  • 6
  • 14
  • Check my answer here
    https://stackoverflow.com/questions/39320825/pojo-to-org-bson-document-and-vice-versa/49918311#49918311
    – kamildab_84 Apr 19 '18 at 11:48

4 Answers4

2

in Spring Data MongoDB you can use

@Autowired
MongoConverter mongoConverter;

Then

TARGET_OBJECT = mongoConverter.read(YOUR_TARGET.class, YOUR_DOCUMENT);
Reza
  • 145
  • 1
  • 2
  • 12
0

You could use morphia (which would mean using mongodb's java driver, or you could use jackson to map back to your POJOs.

evanchooly
  • 6,102
  • 1
  • 16
  • 23
  • I need an asynchronous driver and morphia's async implementation is quite out of date. – Sumit Dhaniya Jun 26 '14 at 21:00
  • Well, morphia doesn't have *any* async support. Anything close would come from the driver itself. 3.x is where all the async work in the driver is happening. Once that lands, we can take a look at what that will mean for morphia. – evanchooly Jun 27 '14 at 13:41
0

You can use Spring Data , it includes integrated object mapping between documents and POJOs.

Sumeet Kumar Yadav
  • 11,912
  • 6
  • 43
  • 80
0

I wanted something for async driver as well. As MongoDB came with Codec Feature in 3.0 version (both sync and async version of driver), it's not neccessary to use libraries such as Morphia anymore so I wrote simple library for mapping POJO into MongoDB myself.

angel
  • 77
  • 10