MongoDB is a scalable, high-performance, open source, document-oriented database. This tag is used for questions related to the Java language bindings and drivers for MongoDB.
I want to use JPA to create an entity class that can be used with the persistence context to access my db2 nosql database. The problem is the @NoSql annotation is not being found.
As per…
I'm trying to write a method that will check if a user_id is in the DB and then operate on the user_id.The portion of code that I'm stuck on is this:
DBObject query = new BasicDBObject(user_id,new BasicDBObject("$regex", true));
DBCursor result =…
This is the code that I was trying to error, and gave me an error.
try {
MongoClient mongoClient = new MongoClient("localhost", 27017);
DB db = mongoClient.getDB("mydatabase");
DBCollection table =…
I am trying to set multiple fields with an update in MongoDB using Java
DBObject nameQuery = new BasicDBObject();
nameQuery.put(DBUser.LAST_SEEN_NAME_FIELD, player.getName());
nameQuery.put(DBUser.LAST_SEEN_NAME_LOWER_FIELD,…
I get this error while trying to insert data from a JSON file. Only one item is added to the database.
11000 E11000 duplicate key error index: awdb.mycollection.$_id_ dup
> key: { : ObjectId('53954d897aadbe032a33cd68') }
> >…
I'd like to confirm that a parser I wrote is working correctly. It takes a JavaScript mongodb command that could be run from the terminal and converts it to a Java object for the MongoDB/Java drivers.
Is the following .toString() result valid?
{…
I have a replica set setup with 1 primary (mongo1.test.com), 1 secondary(mongo2.test.com) and 1 arbiter(mongo3.test.com). When I use MongoClient to connect to them and print out the ReplicaSetStatus, it shows that mongo1.test.com is unconnected with…
I have the following SQL statement
SELECT Currency, TransTime, AuthTime FROM MONIES WHERE Currency not like 'USD%';
If the SQL statement were simply a "LIKE" query, it would yield the following MongoDB statement
db.MONIES.find({
"Currency":…
I have something like this written using mongodb driver for java:
doc = new BasicDBObject("Physicalentity", "Pressure").
append("Sensor", "Tinkerforge").
append("Unit", "Lux").
append("loc", Location).
append("value", pressure).
append("time",…
As I required to import the collection of mongodb from a bson document. How do I achieve that? and I'm using Java. Is there any API for this? Guide me through this.
Thanks in advance
I'm new to mongodb and amazed by the fact that it handles geospatial coordinates and indexing/searching beautifully. However I have a scenario where any help would be appreciated.
I am developing an application that let's user find buses…
I am using mongodb plugin with grails (latest versions).
I have a domain similar to:
class User
{
HashMap baseAddr
static mapWith = "mongo"
}
The User data in DB is like:
{
"_id" : NumberLong(1),
"baseAddr" : {
…