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
36
votes
5 answers

(MongoDB Java) $push into array

I'm using mongo 2.2.3 and the java driver. My dilemma, I have to $push a field and value into an array, but I cant seem to figure out how to do this. A sample of my data: "_id" : 1, "scores" : [ { "type" : "homework", "score" :…
notorious.no
  • 4,919
  • 3
  • 20
  • 34
5
votes
4 answers

Rename ObjectId _id to id in jackson deserialization with Jongo and MongoDB

I've just started working on a project using the play framework,jongo and MongoDB. The project was initially written in Play 2.1 with pojos with an String id field annotated with both: @Id and @ObjectId This would persist to Mongo as an ObjectId…
scalabilitysolved
  • 2,473
  • 1
  • 26
  • 31
5
votes
2 answers

Jongo vs (DBObject)JSON.parse

I'm trying to figure out the advantage of Jongo over simply unmarshalling the json command using (DBObject)JSON.parse(...) and using the DBObject in the below fashion. Is there a performance advantage? @Override public List
Vladimir
  • 2,481
  • 4
  • 31
  • 41
4
votes
0 answers

play.core.server.netty.PlayDefaultUpstreamHandler - Cannot invoke the action java.lang.NullPointerException: null

I got error when i want to fill database in mongodb using PlayJongo. I got this error [error] - play.core.server.netty.PlayDefaultUpstreamHandler - Cannot invoke the action java.lang.NullPointerException: null at…
4
votes
1 answer

Is there a simple way to map a Bson array to Java ArrayList with mongo and jongo?

I'm new to mongodb and I am using jongo. I am trying to map a Bson array to Java ArrayList. Is there a simple way to do that? my pojo- public class Member { @Id String _id; String username; String password; String email; ArrayList
yairbr
  • 69
  • 1
  • 5
4
votes
1 answer

In Jongo, how to find multiple documents from Mongodb by a list of IDs

In mongodb, I can do this by the following query: find( { _id : { $in : [ ObjectId('5275c6721a88939923c3ea54'), ObjectId('5275c6721a88939923c3ea55'), ObjectId('5275c6721a88939923c3ea56'), ObjectId('5275c6721a88939923c3ea57'),…
Jake W
  • 2,788
  • 34
  • 39
4
votes
1 answer

jongo / jackson deserialize scala.option in java

FOUND SOLUTION TO THE PROBLEM For the people who will be stuck like me!: in order to handle third party java or scala Objects for jackson deserialization, you can either use Mixins( but you need to reconfigure the jackson mapper or user…
popo joe
  • 910
  • 1
  • 9
  • 24
4
votes
2 answers

Querying for date using jongo driver for mongo

I use jongo driver to connect to my mongoDB . The syntax for querying - for ex, some age less than 18 - is collection.find("{age: {$lt : 18}}"); but how to query for a date ? In the mongoDB the date key value pair is stored like {"date" :…
user1803112
  • 83
  • 1
  • 5
4
votes
1 answer

Mongo Java drivers & mappers performances

Mongo in Java can be used with several tools: the 10gen official driver an alternative async Java driver a mapper — a library built on top of a driver — Morphia, Jongo... (see complete list) Is there some benchmarks comparing mappers to drivers…
yves amsellem
  • 7,106
  • 5
  • 44
  • 68
3
votes
1 answer

Connection pool in MongoDB with jongo

I would like to use connection pool for MongoDB. I have used MongoDB with Jongo and Spring MVC framework. Here is my spring xml code for MongoDB configuration, which is working fine.
3
votes
1 answer

MongoDriver UUID Support

Im having some issues with mongo driver and the way its inserting UUIDs by default in Java. (Mongo driver version 3.2) UUID("...") => BinData(4, "...") LUUID("...") => BinData(3, "...") legacy UUID in unspecified encoding My UUIDs are being…
WillBroadbent
  • 804
  • 2
  • 8
  • 22
3
votes
1 answer

What is the default target for an annotation when annotating property in Kotlin?

Annotations in Kotlin can have different use-site targets as explained here: https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets My question is: When use-site is not explicitly defined, what is the default target when…
Krešimir Nesek
  • 5,302
  • 4
  • 29
  • 56
3
votes
1 answer

Does list operations load whole data at first call?

Suppose I've got very big collection and I select it by MongoCursor answer = myCollection.find().as(MyClass.class); Will Jongo/Mongo load whole collection at the first call or incrementally load data while I will iterate over answer?
fedor.belov
  • 22,343
  • 26
  • 89
  • 134
3
votes
1 answer

Using Jongo and Jackson 2, how to deserialize a MongoDB ObjectId (represented under String _id in a POJO) to an hexadecimal String representation?

I use the latest version of MongoDB database and the latest version of the official JAVA MongoDB driver. The dependencies that I use in my pom.xml: UTF-8
King-Wizard
  • 15,628
  • 6
  • 82
  • 76
3
votes
2 answers

Creating a dynamic query with MongoDB, Java and Jongo

I'm using a combination of Java, the Play Framework using Java and not Scala, MongoDB and Jongo as my go between for a basic web CRUD app. I keep receiving a JSON parse exception even though my string doesn't contain any illegal characters. It's…
marcus
  • 141
  • 2
  • 10
1
2 3 4 5 6 7 8