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
0
votes
1 answer

hierarchy structure in mongodb with jongo in java?

I have a java project with the following structure: An abstract class Event and other 3 sub classes EventA, EventB and EventB. The code is something like this. public abstract class Event { @MongoId @MongoObjectId private String id; …
user6521061
0
votes
2 answers

Querying by date in mongo db

I am new to Mongodb. I want to find those objects stored in mongodb whose receivedOn date is greater than a particular date. My object structure is : { "_id" : ObjectId("591313fa79a7f2826cdfcdbd"), "uuid" :…
Vivek Mangal
  • 532
  • 1
  • 8
  • 24
0
votes
1 answer

jongo/jackson deserialize a class with generic property

in a java mongo project with complex groupBy requests, i try to deserialize a json like this to { "_id" : { "TAB_COD" : "DOC1", "DON_COD" : "TXEX42030164" }, "count" : 1.0 } to a generic java class like this : public class…
flagadajones
  • 329
  • 3
  • 12
0
votes
1 answer

Comparing save methods through load test between Jongo driver, Java MongoDB driver and MongoRepository

In my diploma thesis I developed REST API for select/save operations between client and database. Data will be post from sensors as JSON and stored in MongoDB . We chose three different technologies for storing: Jongo driver 1.3.0, Java MongoDB…
Peter S.
  • 470
  • 1
  • 7
  • 17
0
votes
0 answers

MongoDB aggregate averages in array based on timestamp

I am new to Mongo aggregation and I am trying to get the following to work. I have the following document: { "gatewayId" : 3, "gatewayReadings" : [ { "timestamp" : 1486570609479, "temperature_1" : 28.5625, "temperature_2" : 30.375, …
MarkH
  • 1
  • 1
0
votes
1 answer

Date and 'polymorphic' class causes JsonGenerationException: BsonSerializer can only be used with BsonGenerator

When updating to jongo 1.3.0 we started to get the following error when reading documents from MongoDB: com.fasterxml.jackson.core.JsonGenerationException: BsonSerializer can only be used with BsonGenerator After some testing I found that the…
Love
  • 1,709
  • 2
  • 22
  • 30
0
votes
1 answer

Java Play 2.5.10 how to inject play-jongo

I've the following model: public class Users { public static PlayJongo jongo = Play.current().injector().instanceOf(PlayJongo.class); public static MongoCollection users() { return jongo.getCollection("DB.users"); …
Enrico Morelli
  • 185
  • 3
  • 16
0
votes
3 answers

Regular Expression to find string starts with letter and ends with slash /

I'm having a collection which has 1000 records has a string column. I'm using Jongo API for querying mongodb. I need to find the matching records where column string starts with letter "AB" and ends with slash "/" Need help on the query to query to…
Kathiresa
  • 421
  • 2
  • 6
  • 15
0
votes
1 answer

How to run query with Jongo to get records between given days?

Using Jongo API to query MongoDB, I can fetch documents from last 5 days with Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); employees.find( "{ createdOn: { $gt: # } }", cal.getTimeInMillis() - 5 * 24 * 60 * 60 * 1000 ); I…
Kathire
  • 53
  • 1
  • 8
0
votes
1 answer

Find Whether users got birthday on a specific date

Say that I've got a collection of users, each with a birthday in ISODate date format. eg. ISODate("1958-03-23T00:00:00.000Z"). How can I use a jongo aggregate query to get users with birthdays on the current day.This is what I have currently but it…
Winnie
  • 89
  • 2
  • 9
0
votes
1 answer

MongoDB document containing sub-document to Java Class with Jongo

I have the following document in a Mongo collection: { "_id" : ObjectId("5757fe72998660e2bc86b85f"), "projectCode" : "ABC", "projectName" : "ABC Dev", "sprintIssueCount" : { "bugs" : 17, "enhancements" : 7, "newFeatures" : 31 } } I am then using…
DJDMorrison
  • 1,302
  • 2
  • 17
  • 34
0
votes
1 answer

Mapping a JAVA object with a MongoDB document using jongo

Hi I have a collection of the following format { "_id" : ObjectId("572eb5df1d739cc73c21f953"), "address" : { "building" : "469", "coord" : [ -73.961704, 40.662942 …
Newton
  • 418
  • 2
  • 9
  • 19
0
votes
1 answer

allowDiscUse when using Jongo

Is there a way to add allowDiscUse: true when using jongo to query MongoDB? I found out that such error - `Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in…
Nikita Buriak
  • 75
  • 1
  • 2
  • 11
0
votes
1 answer

Want to iterate through half of mongoDB and iterate through the rest of the half with another query

I'm getting this error: Exception in thread "main" com.mongodb.MongoCursorNotFoundException: Query failed with error code -5 and error message 'Cursor 304054517192 not found on server mongodb2:27017' on server mongodb2:27017 at …
Nav
  • 19,885
  • 27
  • 92
  • 135
0
votes
1 answer

Play 2.3 Jongo ObjectId to custom ID

I use Play 2.3 scala with play-jongo: "uk.co.panaxiom" %% "play-jongo" % "0.7.1-jongo1.0" I have scala case class: import org.jongo.marshall.jackson.oid.Id case class User(@Id id: String, name: String) When i save some user using Jongo…
kurochenko
  • 1,214
  • 3
  • 19
  • 43