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

Why Jongo 1.0 removed support for private properties

Recently I migrated from Jongo 0.4 to Jongo 1.0, and suddenly I started to receive this exception: ! java.lang.IllegalArgumentException: Unable to set objectid on class: class *Myclass* ! at…
Juraj
  • 161
  • 1
  • 2
  • 11
0
votes
1 answer

How to run a specific command by using Jongo?

I'm using TokuMx in order to organize a transaction. It has specific commands to do so. I tried to run db.runCommand("beginTransaction") in Mongo shell. It worked well. However, when I did the same thing in Jongo: …
lvarayut
  • 13,963
  • 17
  • 63
  • 87
0
votes
1 answer

Jongo create Ref and no embedded object

What is the best way to set an dbRef in entity? I would not save a relation as embedded object in a collection for example. public class Order { @Id @GeneratedValue public String id; private List
articles; } public class…
abuder
  • 1,030
  • 2
  • 13
  • 31
0
votes
1 answer

jongo find subdocuments with array of values

My data looks like this: "_id" : ObjectId("53a173630364206735975b35"), "username" : "TestUserID", "resources" : [ { "id" : "FirstTestResourceId", "tags" : [ "TestResourceTag1", "TestResourceTag2" …
nomester
  • 1
  • 2
0
votes
2 answers

How to get the ObjectId value from MongoDB?

I'm using Jongo with Play framework 2, java. I added some data into my MongoDB. {"_id" : ObjectId("538dafffbf6b562617252178"), ... } However, when I fetched the ObjectId from the database, it gave me…
lvarayut
  • 13,963
  • 17
  • 63
  • 87
0
votes
1 answer

How to deserialize JSON Array contained an abstract class without modifying a parent class?

I'm trying to deserialize JSON Array, which is persisted into my MongoDB, to a Java object by using Jackson. I found many tutorials mentioned to handle this polymorphism by adding: @JsonTypeInfo(use=Id.CLASS,property="_class") to a Super-class.…
lvarayut
  • 13,963
  • 17
  • 63
  • 87
0
votes
2 answers

java.lang.ClassCastException: Cannot cast java.util.LinkedHashMap to Specific class

I want to have common method for inserting and getting objects from MongoDB collection. For all mongo db operations I am using Jongo library. Here's my code: public UserModel getUserByEmailId(String emailId) { String query =…
Amit
  • 451
  • 2
  • 6
  • 19
0
votes
1 answer

$elemMatch inside Jongo query doesn't work

I'm having some trouble with the following query: documents() .find("{values: {$elemMatch: {name: #, value: #}}}", "Date", new DateTime() .withDate(2027, 6,…
Paulo Victor
  • 906
  • 2
  • 10
  • 18
0
votes
1 answer

MongoDb document sub array pagination

I am storing post comments in a post, and the problem I am facing right now is that I cannot use limit with skip on an array of a document, since the users can post as many comments as they want, the array will be huge, So i wanted to paginate the…
popo joe
  • 910
  • 1
  • 9
  • 24
0
votes
1 answer

Mongodb query a sub list

hello I am a mongoDB noob, And I wanted to retrieve a list of comments on a post: { id:0, ref:0, type: 'image', date: null, title: 'this is my title', comments:[ { user : 'myUser', text : 'text' }, { …
popo joe
  • 910
  • 1
  • 9
  • 24
0
votes
1 answer

Play Framework with MongoDB and Jongo

How do I set up a Play project to use MongoDB with Jongo? So far I have installed MongoDB but I don't know how to add it to my Play project, I don't think the documentation tells you how. http://www.playframework.com/modules/mongo-1.1/home I also…
user3037328
  • 25
  • 1
  • 4
0
votes
2 answers

$unwind Addresses from Person collection with MongoDB using Jongo

Hi I am having problems using Jongo to get a list of Addresses from my collection of Persons using the $unwind operator. As you can see I defined the Person class as follows: public class Person { @Id private long personId; private…
nuvio
  • 2,555
  • 4
  • 32
  • 58
0
votes
2 answers

Getting start with Jongo

I'm trying to run an "hello world" with Jongo I added the jar manually (not with Maven) This is the code I ran: public class Friend { @Id private String myId; } public static void main(String[] args) { MongoClient mongoClient = new…
Alon Gutman
  • 865
  • 2
  • 14
  • 22
0
votes
2 answers

MongoDB Java Driver: How to insert into any collection from Java Driver

I have a client facing application with a function that takes in 2 arguments as strings, arg1 is the collection, arg 2 is the function, arg 2 is the hash of the object so in Java I have foo(String collection, String object): /*and I have my db…
0
votes
1 answer

Jongo how to join collections

public Class Team{ @Id String id; String name = ""; } public Class Player{ @Id String id; String team_id = ""; String name = ""; } Ho should i perform the "find" on the MongoDB for having a Team associated to the Player? I'm using…
Lorenzo Sciuto
  • 1,655
  • 3
  • 27
  • 57