barrymac
barrymac

Reputation: 2760

mongodb persistence patterns for JSON client app, jackson mapper or morphia driver?

I've started a new job where they are using mongodb in a java environment.

They have implemented a pattern using DTOs and factories with the morphia driver, this may be due to a migration onto mongodb from a key value store previously. The client is a JSON client.

It seems to me that the jackson-mongo-mapper would be a better approach because it's just mapping pojos from json to BSON and back, seems like it could do away with all DTO factory facade?

Anyone know any pros and cons with these different approaches?

Upvotes: 1

Views: 843

Answers (2)

Tim Spann
Tim Spann

Reputation: 503

Spring Data for Mongodb is very nice since you can use even another data store or mix them and repository interface is very helpful.

Kundera is an option through JPA2 http://agilemobiledeveloper.wordpress.com/2013/08/22/working-with-mongodb-using-kundera/

There's a lot of java to mongodb options.

http://www.agilemobiledeveloper.com/2013/01/31/hibernate-ogm-mongodb-vs-kundera-vs-jongo-vs-mongodb-api-vs-morphia-vs-spring-data-mongo-mongodb-drivers-for-java/

Adding your own data layer and making sure you use DI and test it fully is very helpful.

NOSQLUnit is awesome -> https://github.com/lordofthejars/nosql-unit

Upvotes: 1

Tim Spann
Tim Spann

Reputation: 503

DTOs are good for keeping a separation between implementation and design, so when they need or want to switch from mongo to some other NoSQL or SQL database it can be done cleanly.

Upvotes: 0

Related Questions