Questions tagged [mongodb-java-3.3.0]

The tag is useful for mongodb java driver version 3.3.0 for newly added features. This would be used most of the time along with the mongodb-java tag.

New features of the 3.3 java driver included:

  • Cluster Monitoring in the synchronous and asynchronous drivers
  • Command Monitoring in the asynchronous driver (support in the synchronous driver was added in a previous release)
  • Additional query parameters in the connection string
  • GridFS in the asynchronous driver
  • Additional configuration options for GSSAPI authentication.
  • JNDI ObjectFactory implementation
23 questions
6
votes
2 answers

Finding distinct from collections in mongodb

Our previous implementation for finding distinct elements from a collection used to be : List names = mongoClient.getDB(dbName).getCollection(collectionName).distinct(NAME_KEY); Trying to upgrade this into the current implementation with…
Naman
  • 27,789
  • 26
  • 218
  • 353
3
votes
2 answers

Difference between MongoCursor vs FindIterable

I want know what is the difference between MongoCursor and FindIterable. MongoCursor: MongoCursor cursorPersonDoc = personDocCollection.find(whereClauseCondition).iterator(); while (cursorPersonDoc.hasNext()) { Document…
3
votes
1 answer

What is the correct method to update a document while using Mongo Cursor?

I am trying to update a document in Mongo DB using cursor. My Mongo DB Java driver version is 3.3.0. Following is my code snippet. MongoCollection collection = mongoDb.getCollection("customer"); MongoCursor cursor =…
RLD
  • 1,867
  • 3
  • 15
  • 20
2
votes
1 answer

MongoDB query: filter and exclude fields

I have the following data structure: { "groups" : [ { "internalName" : "Group1", "fields" : [ { "internalName" : "Field1", "uiProperties" : { "isShow" : true …
2
votes
3 answers

How to read date (Timestamp) from MongoDB using Java

Am trying to read date field from MongoDB in below format Formate: YYYY-MM-dd HH:mm:ss.SSSSSS 2017-01-23-10.46.07.812000 - DB2 2017-01-23T16:46:07.812Z - Stored in MongoDB (While viewing from GUI tool) Mon Jan 23 22:16:07 IST 2017 -…
Bharathiraja S
  • 679
  • 4
  • 12
  • 26
1
vote
0 answers

Cannot find a public constructor for 'Optional' java mongodb driver

I have register codec registry for POJOs as below @Singleton public record Repository(MongodbConfiguration mongodbConfiguration) implements IRepository { @Override public MongoCollection getCollection(String collectionName, Class
San Jaisy
  • 15,327
  • 34
  • 171
  • 290
1
vote
0 answers

Get Mongo db id after insertion in case of POJO class

I have a POJO class in java @Data @EqualsAndHashCode(callSuper = false) @NoArgsConstructor @AllArgsConstructor public class TestModel{ protected ObjectId id; private String name; } Is there any way to populate id field in case of insertion.…
Lakshay Jain
  • 446
  • 1
  • 3
  • 17
1
vote
0 answers

Mongodb Aggregate Date match in Java

I have below Mongo DB aggregate query which is giving me the below output Sample Documents in Mongodb /* 4 */ { "_id" : ObjectId("5a536d89e5b8f73d4e41ba96"), "name" : "yyyyy", "creationDate" : ISODate("2018-01-02T16:27:25.201Z"), …
1
vote
1 answer

Mongo db java driver query convert

I have the following data structure [{ "id": "1c7bbebd-bc3d-4352-9ac0-98c01d13189d", "version": 0, "groups": [ { "internalName": "Admin group", "fields": [ { …
1
vote
0 answers

I need to rename one field in document

Here is the code : AggregateIterable result = chatLogCollection.aggregate(Arrays.asList( new Document("$match", new Document("displayName", "user")), new Document("$group", new Document("_id","$sessionGUID") …
Kit
  • 273
  • 3
  • 5
  • 16
1
vote
1 answer

Duplicate the group by field value

I am trying to execute following code: MongoDatabase db = MongoDatabaseConnector.getDatabase(); MongoCollection chatLogCollection = db.getCollection("chatLog"); AggregateIterable result =…
Kit
  • 273
  • 3
  • 5
  • 16
1
vote
1 answer

DBCollection save() equivalent in mongo 3.3

Our current implementation with mongo-java-driver:3.0.4 for a document update is as follows - private void updateParam(String param1, String param2) { Param param = new Param(param1, param2); DBCollection collection =…
Naman
  • 27,789
  • 26
  • 218
  • 353
1
vote
1 answer

Fetch _id of a Document in MongoDB 3.3.0 above

Trying to refactor a lot of code from one of our services I ended up using a piece of code as : Document documentObject; String docMongoId = ((DBObject) documentObject).removeField("_id").toString(); which though not on compiling but during…
Naman
  • 27,789
  • 26
  • 218
  • 353
0
votes
1 answer

How to Set the URI for the ClusterSettings with codec in mongodb java driver

I am using the codec for the serialization and deserialization of POJO using 4.3/driver-reactive http://mongodb.github.io/mongo-java-driver/4.3/driver-reactive/getting-started/quick-start-pojo/ @Singleton public record…
San Jaisy
  • 15,327
  • 34
  • 171
  • 290
0
votes
1 answer

How to implement mongo project stage compute in java driver?

I want to compute a new field using project stage in aggregation pipeline in Java driver. I want create new field by just multiplying value (that is coming from previous stages) with 100. Bson projectGroup= Aggregates.project( …
1
2