8

What is in your experience a good Java API for MongoDB?

I am searching for something with annotation based mapping of Java POJOs to MongoDB resources and a decent query abstraction layer.

4 Answers 4

6

Try Morphia http://code.google.com/p/morphia/

It works really well (haven't encountered any problems with it), eventhough it's still pre-1.0.

Sign up to request clarification or add additional context in comments.

1 Comment

Can we use Morphia with gridfs?
3

The Spring data framework might be an alternative

http://static.springsource.org/spring-data/data-document/docs/current/reference/html/#mongo.core

Objects look like this

@Document
public class Person {

  @Id
  private ObjectId id;

  @Indexed
  private Integer ssn;

  private String firstName;

  @Indexed
  private String lastName;

}

Querying can be done via automagical Repository interfaces, or with mongoTemplate which looks like this:

List<Person> result = mongoTemplate.find(query(where("age").lt(50).and("accounts.balance").gt(1000.00d)), Person.class);

1 Comment

Thanks for the answer, but you might want to try out their statically typed queries. I've heard they are quite useful.
2

Used both on two different projects. Started out using Morphia but lack of support by main developer limited us. Even though 10gen hired Morphia developer, support for Morphia seemed to be wavering.

When I asked 10gen folks about their plans for Morphia I got no clear response. We switched to spring data on other project and API seems more complete and better docs and community.

Comments

1

I think that the lightest and well documented is Jongo (jongo.org). It can be a good and fast option.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.