Fork me on GitHub
mongolink
mongolink

An Object Document Mapper (ODM) for Java and MongoDB

GitHub »


MongoLink was conceived to leave no footprints at all (or almost) on your project : no annotations, no super class to inherit. Mapping is declared through a fluent api directly in Java, and the configuration to get started is just a few lines long.

Quick start

Here is a sample project, that should get you up and runnning quickly

Install

You must of course install MongoDB. Then the simplest way to go is to use Maven, Gradle, or wathever build tool you fancy. Here is a sample configuration for Maven : Keep in a mind we also provide a snapshot repository for the more bleeding edge versions of MongoLink

Configuration

To work with MongoLink, you must use MongoSessionManager and MongoSession. MongoSessionManager is more or less a factory for MongoSession, and you may have only one instance of MongoSessionManager for your application.

Mapping

Mapping with MongoLink is only declared through code :  The «magic» here occures with the element() function. It returns an entity interceptor that let MongoLink register your functions. MongoLink will deduce your field names from functions.

You can also declare Value objects that can be use as properties of other objects : 

Saving

Once you have a MongoSession instance, saving an entity is quite easy :

Reading

Retrieving an entity with its Id is also fairly easy : For more complexe scenarios, we are working on a criteria api :

Updating

Updates are automatics with MongoLink. Since all your work is encapsulated in a MongoSession, it can generate the update query that matchs your modifications. A simple call to mongoSession.stop() will do the trick :  MongoLink supports two update strategies : 
  • DIFF : generates only the modifiers needed
  • OVERWRITE : writes the whole document each time

Deleting

Once again, when you have a MongoSession, deleting is fairly easy :

Unit Testing

MongoLink provides a simple junit rule te ease unit testing. It will :
  • Setup MongoLink with Fongo
  • Provide utility methods, as cleaning session

License

MongoLink is free software: you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

Credits

MongoLink was created by Jean-Baptiste Dusseaut for Arpinum

David Dumon and Charles Couillard contribute greetly.

For a complete contributors list, see this file

Logos by Cédric Néhémie.