• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using MongoDB in Java

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recently began working with MongoDB in java.

I am right now stuck with what to use?
I read a lot about Data persistence in Java and have narrowed it down to these options

1. Pure JDBC
2. Spring JDBC with Spring Mongodb
3. Datanucleus (and why not pure JDO)
4. Kundera JPA (Its support for MongoDB)


Case 2 : If in future if I plan to use some other NoSQL database which will benefit me greatly
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want a database-agnostic library that you can use with other NoSQL databases as well as SQL databases, then I guess Spring Data might be your best option. Not sure how many NoSQL databases are supported, and it may be more trouble than it's worth for simple applications. I'm not sure how easy it is to swap out e.g. MongoDB for Neo4J or PostgreSQL even with Spring Data's supposedly generic approach.

If you are looking specifically for Java MongoDB drivers, you could start with the official Java driver, which now includes support for asynchronous processing (good for scalability), and is fairly well documented on the MongoDB website: http://docs.mongodb.org/ecosystem/drivers/java/

If you want to find out more about how to use MongoDB with Java, you could try the free online course M101J MongoDB for Java Developers.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a project using Spring Data for Neo4j (also known as "SDN"). You can see it at https://github.com/mtsinc1/Dibs.

At the moment, the Neo4j interface isn't very portable, I fear, and one thing that I'm used to having when using Spring is transparent transaction support. Which, for some reason I (and others) have a lot of trouble getting to work properly in SDN at the moment, which is why the code is infested with manual transaction management.

Spring has several advantages. It provides a general Inversion of Control architecture to programs - not just database stuff, but all sorts of things. I use it to swap in and out dummy emailer modules for testing, as an example.

In the database realm, it provides good ORM support, does the grunt work that goes around database functions, such as getting and releasing connections and genericized error handling and - except as noted above - it's pretty good about transaction handling as well.

Although Spring does try to abstract things, the Neo4j approach is pretty different from traditional SQL databases, since it's predicated more on the relationships than the data. MongoDB is probably easier to swap back and forth with SQL-oriented stuff.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic