Questions tagged [jongo]

Jongo allows to query in Java as in Mongo shell; unmarshalling results into Java objects (by default with Jackson).

Jongo

Using Mongo with its Java driver can be tricky: querying, mapping results and handling polymorphism require lots of code. Some libraries aim to simplify this (like Morphia), but none allow to query in a shell fashion.

Jongo tries to fill that need, querying with the use of strings "{age: {$gt: 18}}" and unmarshalling results into Java objects (by default with Jackson):

DB db = new Mongo().getDB("dbname");

Jongo jongo = new Jongo(db);
MongoCollection friends = jongo.getCollection("friends");

friends.find("{age: {$gt: 18}}").as(Friend.class)
111 questions
1
vote
2 answers

MongoDb and Jongo - escaping a hash (#) in field

I'm trying to read data that has been saved in MongoDB and de-serialise it back into a POJO, using Jackson/Jongo. This works fine when the fields do not contain a hash. When the fields include a hash, Jongo thinks this is a placeholder so expects…
user3812127
  • 75
  • 1
  • 4
1
vote
1 answer

How to serialize ObjectId to JSON?

I want to serialize ObjectId of my Product class to JSON. I got the following JSON: [{"name":"Play for Java: Covers Play 2","type":"Book","company":"Manning…
lvarayut
  • 13,963
  • 17
  • 63
  • 87
1
vote
1 answer

Update / delete multiple objects using Jongo

I have a method which takes in a Collection of Objects that are to be deleted. This is the way I am deleting them now public void deleteAll(Collection objs){ for(Object obj : objs) { collection.remove("{ _id: # }",…
hpkancha
  • 96
  • 3
1
vote
0 answers

UTF8 - CharsetEncoder#encode() - Infinite Loop

We have a Play 2.2.1 application that's using the plugin jongo to managed MongoDB access and object mapping. This plugin uses a library called bson4jackson to adds support for BSON to the Jackson JSON processor. We can handle hundreds MB of UTF8…
Shoxolat
  • 97
  • 2
  • 9
1
vote
2 answers

Jongo Maven Dependency causing problems

I am currently trying to use the Jongo project to connect to a remote MongoDB. To do so, I added these dependencies to my project : org.jongo jongo
Thibault
  • 568
  • 3
  • 10
  • 21
1
vote
1 answer

Efficient handling of saving Object data with image in MongoDB

Here i want to save one object to MongoDB using Java. I found Morphia, Jongo, Springs are providing framework to achieve it. To store the images to mongoDB i found GridFS Here my problem is, 1. I have one object it contains both data as well as…
Suseendran P
  • 557
  • 1
  • 5
  • 18
1
vote
1 answer

Java/Mongo Query with geoLocation and within specified timeframe

I am having some issues retrieving the correct date within a particular radius from MongoDB. I have a json example shown at the bottom. My goal is to search for all items close to a defined geolocation as well as filtering on a starttime. This…
LanceP
  • 974
  • 1
  • 9
  • 15
1
vote
2 answers

Manual references support

Consider the class: class Person { String name; Person father; Person mother; List children; } Is there a way to indicate to jongo that father, mother and children should be manual references to other objects within the same…
assylias
  • 321,522
  • 82
  • 660
  • 783
1
vote
2 answers

How to get jar lib files of jongo?

Follow at jongo a java library on top of MongoDB allow Query in Java as in Mongo shell. Example: SHELL db.friends.find({"age": {$gt: 18}}); JAVA DRIVER friends.find(new BasicDBObject("age",new BasicDBObject("$gt", 18))); JONGO friends.find("{age:…
Sonrobby
  • 3,112
  • 8
  • 30
  • 38
1
vote
1 answer

Mongo : morphia doesn't map the _id in a jongo request

These are my objects : @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) public abstract class AdtagEntity extends GenericEntity implements Serializable { private static final long serialVersionUID = -6624915864457400750L; @Id …
pauline
  • 87
  • 1
  • 8
0
votes
1 answer

How do I confirm I am reading the data from Mongo secondary server from Java

For performance optimisation we are trying to read data from Mongo secondary server for selected scenarios. I am using the inline query using "withReadPreference(ReadPreference.secondaryPreferred())" to read the data, PFB the code snippet. What I…
Dinesh
  • 11
  • 1
0
votes
0 answers

Use 'arrayfilters' to update the sub array using Jongo

The following query works in the MongoDB console. db.getCollection('safetyPlan').update({"user": "username"}, {"$set": {"stepItems.$[i].items.deleteFl": true}}, {"arrayFilters": [{"i.items._id": new ObjectId("3w43esrw3er2343rsfsdf333")}]}); The…
BraveNinja
  • 203
  • 3
  • 11
0
votes
1 answer

mongodb update not working on nested subdocument

My mongodb records are like in this link Updating nested array inside array mongodb and sample records are as below and want to update a field in the nested document "parameter" array provided it satisfies some conditions (_id : "04", operations._id…
chiku
  • 485
  • 2
  • 8
  • 23
0
votes
1 answer

Using jongo runcommand for regex

How to use jongo runcommand to execute regex for the below example : Command command = jongo.runCommand("{" + "find : 'sales', filter : {$and : [{date : {$gte : #}}," + "{date : {$lte : #}}, { name: { $regex: /^TEST/ }…
chiku
  • 485
  • 2
  • 8
  • 23
0
votes
0 answers

Adding objects into array in Jongo Java Play Framework

Below is the template of my Class.java file: class : "AB" member : [] where departments will have array of departments like below: email : yuna13.com, //from User.java email : katy89.com, ... so the final array structure i want…
user8352817