mongodb « mongodb « Java Database Q&A

1. Is MongoDB a valid alternative to relational db + lucene?

On a new project I need a hard use of lucene for a searcher implementation. This searcher will be a very important (and big) piece of the project. Is valid or ...

2. Working with mongodb from Java

I have launch mongodb server:

[][~]% mongod --dbpatmongod --dbpath /home/demas/temp/  
Mon Apr 19 09:44:18 Mongo DB : starting : pid = 4538 port = 27017 dbpath = /home/demas/temp/ master = 0 ...

3. Directory Hierarchy

How to build a folder structure using morphia or the mongodb API? I am looking for something like this.


4. How to get a properly typed List from a ReflectionDBObject

I have a model classes like

public class MyClass extends ReflectionDBObject {
    private List<NiceAttribute> attributes;    

public class NiceAttribute extends ReflectionDBObject {

5. Java API for MongoDB

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 ...

6. mongoDB utility class

Is there a "MongoUtil" class that allows me to get a new connection in a multi-threading environment (like the so famous HibernateUtil class)? Thanks

7. Secondary-only nodes in mongodb Replica set

I am working on a project where I want to have the ability to specify that certain nodes of the replica set can never be primary nodes ie in case of ...

8. mongoDB injection

is there a common pattern in Java to avoid mongoDB injection attacks? Thanks

9. How to get values of inner document attribute in mongoDB?

i am new to mongoDB. I am using mongoDB in web app. I want to know how to get the value of inner document attribute of a document. Lets say my JSON ...

10. What kind of tools are available for populating test data into mongodb

What kind of tools are available for populating test data in mongodb. We have used dbunit in the past, but it doesn't seem to have an equivalent maven plugin. ...

11. MongoDB equivalent of WHERE IN(1,2,...)

I have a list of userIDs and I want to pull out every document (naturally ordered) from a collection that are associated with one of these user IDs. Is there a ...

12. MongoDB API for Java : MongoInternalException on accessing a DBCursor

After successfully connecting to the MongoDB database, I'm receiving this exception when trying to go through a DBCursor :

Exception in thread "main" com.mongodb.MongoInternalException: couldn't get next element 

13. How to specify Multiple conditions in Java Mongo

HI, I have a code which requires me to get user details from a mongo database collection Following is one of the field in my Users collection

"emailSettings" : {

14. Mongo/Java findAndReplace not working

I have a Mongo collection like this

"isConfirmed" : true/[or false]
"email" : "xxxxxxxxxxx"
When I am trying to update the isConfirmed field to true or false, depending on the email which apparently is ...

15. mongo + java + too many open files

I am using mongo-java2.4jar for communicating with the mongo server. In my webapp i am using mongo=new Mongo("serverIp","port") where ever it is required and once the processing is complete, i am closing ...

16. Mongo+Java+SocketTimeOut

I am using MongoDb and I am facing problems while reading the records from the DB. I am able to get them in the cursor but when I try to get the ...

17. How to specify UUID in mongo $where clause

I have an object that was stored via mongo-java-driver. Object uses java.util.UUID for its _id field. Following is presentation of object via mongo shell:

> db.b.find()
{ "_id" : BinData(3,"zUOYY2AE8WZqigtb/Tqztw==") }
I have a ...

18. mongodb: storing a hierarchical tree structure?

on the mongodb, how would I go about storing a hierarchical tree data in which each node contains a Java object containing it's own set of string variables and objects? If ...

19. Java - memory usage & multiple instances of jar

I am currently working with Java, MongoDB and several threads. For each threads, I run MongoDB connection.

private Mongo m;
m = new Mongo();
I had a look to the memory usage with TOP and ...

20. Read issue in MongoDB asynchronous replication

I'm new to MongoDB. I created a Java app using MongoDB as database. I configured 3 servers in a replica set. my pseudo code: { createUser getUser updateUser } Here createUser creates the user successfully but getUser fails to ...

21. java.lang.ClassCastException even though I am casting it to the extended class

I am trying to setup a mongo-hadoop driver extensions for the hadoop streaming jobs I have written for the python plugin dumbo. The dumbo project needs me to ...

22. MongoDB Java API: put() vs append()

I am new to mongodb and as I going through the tutorial for Java & Mongodb. I notice there is put() and append() for BasicDBObject and I took a look at ...

23. Java - InstanceAlreadyExistsException with Mongodb

I am doing multithreading with Mongodb and sometimes I have this message when running my script :

8 juil. 2011 14:13:59 com.mongodb.DBPortPool$Holder get
ATTENTION: jmx registration error: com.mongodb:type=ConnectionPool,host=,port=27017,instance=1593488603 continuing...
I checked on Mongodb ...

24. Setting a inner document attribute in MongoDB with Java API

I am struggling to figure out the correct way to update/insert a new attribute into an inner document. Everything i am trying is just not working.

{ "a" : true, ...

25. java - MongoDB + Solr performances

I've been looking around a lot to see how to use MongoDB in combination with Solr, and some questions here have partial responses, but nothing really concrete (more like theories). In ...

26. Cloud for Flex, Java, mongoDb?

I am about to develop my masters project using Flex as front end, BlazeDs, Java Web Services and MongoDB in the backend. I am looking to deploy and manage it on ...

27. Dealing with schema changes in MongoDB

I use MongoDB in one of my Java projects. After a DB schema change, I found myself modifying existing code at a lot of places to perform the change from e.g.:

Object ...

28. Can I use MongoDB for Java Content Repository?

Can I use MOngoDB for JCR storing file (xml file)?

29. mongodb+mockito doesn't work together?

I'm trying to setup mocks for mongodb in my java code, and I'm getting the following exception:

DBCursor$$EnhancerByMockitoWithCGLIB$$fc4f0e22 cannot be returned by getOptions()
getOptions() should return int
The line of code that generates this ...

30. mongodb dbrefs examples using Java

I tried to find working examples of java/SpringData mongodb DBRefs but couldn't find any. I'm new to Mongodb and looking for ways to use SQL join-like functionality to aggregate/merge data from ...

31. Storing and getting documents from MongoDB

I need to provide a way that my mongodb server will store each document id as long integer (64-bit) starting from 0 and increment as document is inserted. Here's a kind of ...