Sunday, January 24, 2016

HowToRunIt

1. This is how your eclipse should look like, after importing.

2. Start mongo.

3. Build And Jetty.

4. Mongo Running.

5. Building.



6. Ignore the first error.


7. Ignore the second error.

8. Start Jetty.


9. Add a big fruit.



10. See Mongo console for the big fruit



11. See the fruits in browser.


Is ODM Needed For Mongo

This is a simple blog about ODM for Mongo.

Though not ideal, sometimes Mongo needs to be used with JAVA, by following the Document model.Why not ideal to use with Java ? What is ideal to use Mongo with ? When to use Mongo ? are all separate questions…Short answer for now is depending on data,read/write which intern depends on use case.

The first tendency comes to look for an ODM, that is equivalent to ODM in a relational database.

ODM for Mongo is not necessary , an additional abstraction and likely lead to poor design choices. A simple mapping framework(say ODM Mapping), that does mapping and mapping only is sufficient.

This allows to use Mongo , to its full capabilities….DB engine based encryption, sharded connection etc.Plus Mongo Java driver is more close to object model any way..

Ok. Now so what approach to take ?

Choose an ODM mapping (not really a word, i coined it), that is least intrusive on your POJO’s.

Using an ODM like Hibernate, forces you to add mapping annotations on your Domain object, limiting its portability and componentization, domain sharing.

I personally like lib-mongo, as it is purely mapping.Lot of defaults, but no provision to map/customize. Say you cannot map “personName” to “fullName” in the Mongo db document object, say the persistent Object and the additional caveat of copying the bean’s properties in complex structures.

Mongo-link is also good, because it uses a generic interface at the DAO layer. However it does require you specify each mapping…

An ideal solution would be a mapping framework, with defaults that can be overridden. If i get some time, i will throw in one…


For the time being, please refer the link below for a working example of Mongo link.I took the example from MongoLink’s site and added minor updates to make it work on my mac, with Debug statements. I will check in more changes, make it more friendly to download and use , pointing out the caveats at the same time...Enjoy.

References And how to run it on next page.