Questions tagged [mongojack]

Mongojack is a library that facilitates mapping between Java objects and MongoDB documents.

Since MongoDB uses BSON, a binary form of JSON, to store its documents, a JSON mapper is a perfect mechanism for mapping Java objects to MongoDB documents. And the best Java JSON mapper is Jackson. Jackson’s parsing/generating interface fits serialising to MongoDBs documents like a glove. Its plugins, custom creators, serialisers, views, pluggable annotators and so on give this mapping library a massive head start, making it powerful, performant, and robust.

Features

  • Deserialises queried objects directly from the MongoDB stream, making it one of the (if not the) fastest object mappers for MongoDB out there.

  • Uses Jackson for object mapping, so compatible with most Jackson features, including custom serialisers and deserialisers, creators, views, annotation introspectors, etc.

  • Wraps the MongoDB driver DBCollection, providing most of the original methods, plus strongly typed versions.

  • Gives low level access to advanced MongoDB driver features.

  • Supports querying using objects as templates, and selecting fields to return using objects as templates.

  • Supports mapping ObjectIds to strings and byte arrays, using an @ObjectID annotation.

  • Supports @javax.persistance.Id annotation for marking which property is the id (or just call it _id).

  • Provides interface to building update commands with update modifiers, which supports POJOs which will be serialised by Jackson.

  • Provides terse chained query builders

  • Supports database reference conventions, with convenience methods for fetching references and collections of references in one query.

Reference :

http://mongojack.org/

33 questions
1
vote
1 answer

Cannot deserialize localdatetime using mongo and mongojack

I have a simple pojo import lombok.Data; @Data public class DataPojo { private LocalDateTime myDate; } When I try to read the pojo from mongo + mongojack MongoCredential credential = MongoCredential.createCredential(userName, "aDb",…
Jeff Benton
  • 146
  • 1
  • 8
1
vote
1 answer

Dropwizard returns 400 on valid GET

I'm developing a Dropwizard app and am facing a strange bug on a GET request after I have included mongojack. I have a simple GET query with the ID as a path parameter. It worked before I included mongojack and added two annotations to my…
EagleBeak
  • 6,939
  • 8
  • 31
  • 47
1
vote
1 answer

Mongojack- how to create composite Primary key

We are using mongodb & MongoJack for mapping our collections. There is a need where we need to create composite primary key. We are not getting correct configuration how to use @Id annotation. Can anyone help in this or should we avoid using…
Raichu
  • 117
  • 1
  • 11
1
vote
1 answer

MongoJack support @javax.persistance.Id doesn't work

I am using MongoJack (2.0.0) to serialize/deserialize objects from MongoDB. According http://mongojack.org/index.html MongoJack should support @javax.persistance.Id. I have annotated object variable with @Id @Id private String id; When I try to…
Tuno
  • 1,234
  • 1
  • 13
  • 22
1
vote
2 answers

javax.persistence.Transient (@Transient) is not working with MongoDB while updating

I am trying to use @Transient (javax.persistence.Transient) in one of my entity, it works fine for inserting the records (the Transient fields are not stored in DB which is OK) but when I am trying to update the same entity the Transient fields…
0
votes
1 answer

How to fix limit and orderBy in Mongodb using Java

I am trying to fetch a list of documents using specified filters. I want to limit the output to 10 and orderBy a column of type long(totalTransactionCount that is found in the sample data posted below). However, the output I get is just 8 instead of…
CuriousCat
  • 25
  • 5
0
votes
2 answers

How to insert Date object with the latest mongojack?

so in my object, I have private Date date; when I insert I got this exception: Caused by: com.fasterxml.jackson.databind.JsonMappingException: JsonGenerator of type org.mongojack.internal.object.document.DocumentObjectGenerator not supported:…
FeeLGooD
  • 386
  • 4
  • 18
0
votes
0 answers

Is there a have MongoJack work with BSON Date

By default it looks like mongojack stores DateTime as a long in Mongo. Is there a simple way to have it store the dates as BSON Date instead? For example the following ends up as a long in Mongo and I'd want to have a BSON…
Kohl
  • 11
  • 1
  • 2
0
votes
1 answer

What Java Model object options are available when writing to MongoDB?

I am developing a small java application thats employing ModgoDB as its database. I do not want to have to build my data using Document so I thought to use MongoJack. however MongoJack doesnt seem to support MongoCollection's. Also I never seem to…
Hector
  • 4,016
  • 21
  • 112
  • 211
0
votes
1 answer

Mongodb update or insert with mongojak - Java

I’m new to MongoDB and Mongojack , I’m trying to update a document if it is already exit or else insert a new document. For testing purpose I use below code which is button click event. My problem is when I click the button for the first time it…
user2486322
  • 847
  • 3
  • 13
  • 31
0
votes
1 answer

JacksonDBDecoder - Server errors from MongoDB - mongojack 2.3.0

I have a problem when my application receives an error from MongoDB server, for example: Imagine that I do a find in MongoDB but the response from MongoDB Server is an error because of a timeout: { $err: "MongoTimeout due to...bla bla bla..." code:…
pakkk
  • 289
  • 1
  • 2
  • 13
0
votes
1 answer

JacksonDBCollection findOne query and not working java

I am trying to implement a findOne query on JSON: My JSON looks like this: { "_id":{ "$oid":"5613b8d360b292805a5d7f2d" }, "resellerId":"1" .... } And here is my Java code: final JacksonDBCollection resellerWidget =…
0
votes
2 answers

Create mongodb query dynamically

I have a collection, say, test which contains some 100 fields like _1, _2, _3 etc Now I want to form MongoDB query such that whatever input comes like 1, 2, 5 or 5, 6, 7, 8, 9. A proper query can be generated. Please help with respect to MongoJack.
rohitanand
  • 710
  • 1
  • 4
  • 26
0
votes
0 answers

Ignoring methods when saving an Object with mongojack

I am currently working on an java application that stores Objects in a mongoDB using mongojack. Everything worked fine until I started to implement some helper methods in the Object to return directly nested Objects instead of the DBRef. public…
LST
  • 345
  • 4
  • 13
0
votes
1 answer

Mongojack possible to persist id as string

Is is possible to store the id field of type String in a POJO as a String in a mongo collection? I've tried to annotate the POJO as described in the official documentation, but the _id collection property is always persisted as an ObjectId. Here's…
Nick Hammond
  • 193
  • 13