jongo

Mongo Java drivers & mappers performances

天大地大妈咪最大 提交于 2019-12-05 13:05:11
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 performances and one versus each others? Unfortunately, there are no benchmarks that I am aware of. The driver home page is here (but I'm guessing that you probably know that) and the Java Language Center containing all information related to Java for MongoDB. There is quite a bit of work going on with the Java drivers at present afaik but no

How to serialize ObjectId to JSON?

北城余情 提交于 2019-12-04 21:50:55
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 Publications","price":30.0,"imagePath":"public/images/play-for-java.png","rating":4.5,"category":"Computer","author":"Nicolas Leroux","publicationDate":1396224000000,"numPage":320,"_id":539da7a6370882f10d5c2777}] You can notice that the "_id" didn't be properly serialized, it should be "539da7a6370882f10d5c2777" (with double quotes) and not just 539da7a6370882f10d5c2777 . Therefore, I have tried to implement my own ObjectIdSerializer as

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

ⅰ亾dé卋堺 提交于 2019-12-04 13:59:55
In mongodb, I can do this by the following query: find( { _id : { $in : [ ObjectId('5275c6721a88939923c3ea54'), ObjectId('5275c6721a88939923c3ea55'), ObjectId('5275c6721a88939923c3ea56'), ObjectId('5275c6721a88939923c3ea57'), ObjectId('5275c6721a88939923c3ea58') ] } } ) But how can we do the same using Jongo code? I know we can find one document via: db.getCollection("mongoEg").findOne(Oid.withOid("5194d46bdda2de09c656b64b")).as(MongoTest.class); But how to get more than one documents in one query via Jongo? yves amsellem I see two options to achieve a find on multiple ids: // 1. find with an

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

流过昼夜 提交于 2019-12-03 22:47:53
问题 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 annotating property in a class like in the example below? class Test { @SomeAnnotation var someProperty: String? = null } Background I'm trying Jongo as MongoDB client in Kotlin and have problems annotating id field. Jongo does not map id property

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

回眸只為那壹抹淺笑 提交于 2019-12-01 00:35:24
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 annotating property in a class like in the example below? class Test { @SomeAnnotation var someProperty: String? = null } Background I'm trying Jongo as MongoDB client in Kotlin and have problems annotating id field. Jongo does not map id property correctly when it's annotated like this: @MongoId @MongoObjectId var id: String? = null The annotations

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

岁酱吖の 提交于 2019-11-28 08:22:45
问题 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 and when deserialized would output the id as: "id":"53fcb9ede4b0b18314098d10" for example. Since upgrading to Jongo 1.1 and Play 2.3.3 the id attribute is always named "_id" when deserialized, I want the attribute to retain the field name yet I can't

(MongoDB Java) $push into array

醉酒当歌 提交于 2019-11-26 09:36:31
问题 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\" : 78.97979 }, { \"type\" : \"homework\", \"score\" : 6.99 }, { \"type\" : \"quiz\", \"score\" : 99 } ] I can $push in the shell: db.collection.update({_id:1},{$push:{scores:{type:\"quiz\", score:99}}}) but it\'s when I translate this into java I confuse my