Questions tagged [spring-mongodb]

Do not use this. Use [spring-data-mongodb] instead.

Do not use this. Use instead.

422 questions
0
votes
0 answers

Spring mongodb aggregation pipeline

MatchOperation matchDepartmentStage = Aggregation.match(Criteria.where("department").is("DEPT_A")); ProjectionOperation projectEmployeeStage = Aggregation.project() .andExpression("concat(emp_name,'-', emp_age)").as("emp_name_age"); Criteria…
Winster
  • 943
  • 10
  • 28
0
votes
2 answers

Building ArrayFilters update in Spring Data MongoDB with MongoOperation

I am using Spring boot 2.2.1.RELEASE. How can I write the below MongoDB update query with Spring MongoOperation db.cities.updateOne( { _id : ObjectId("5e78ec62bb5b406776e92fac") }, { $inc: { …
Meena Chaudhary
  • 9,909
  • 16
  • 60
  • 94
0
votes
2 answers

How to add a json in a nested array of a mongodb document using Spring?

Document stored in mongodb: { "CNF_SERVICE_ID":"1", "SERVICE_CATEGORY":"COMMON_SERVICE", "SERVICES":[{ "SERVICE_NAME":"Authentication Service", "VERSIONS":[{ "VERSION_NAME":"AuthenticationServiceV6_3", …
Sangames Kumar
  • 45
  • 2
  • 10
0
votes
1 answer

Conditional/max mongo queries using spring mongoTemplate

I have hundreds of records like these in a mongodb collection: { "city" : "London", "eventTime": 1582866000, "createdTime": 1582900145, "eventDetails: { ... } } This is corresponding the Event class public class Event…
Prady
  • 165
  • 1
  • 15
0
votes
1 answer

Store a base64 image in mongodb using ReactiveGridFsTemplate Spring Webflux

Previously, i was able to store a base64 image using GridFsTemplate as below. val imageBytes = javax.xml.bind.DatatypeConverter.parseBase64Binary("base64 image string") gridFsTemplate.store(ByteArrayInputStream(imageBytes), "imagename") However the…
0
votes
0 answers

Generic Search and Filter by dynamic fields for Criteria (Global Search)

I have a scenario where I need to add Criteria to perform search and filter in Spring using mongoTemplate. Scenario: Lets say I have Student, Course and PotentialStudent. and I have to define only certain fields to be used for search and filter…
0
votes
1 answer

MongoDB join two collection

This is the order entity: public class Order { @Id private String id; private String internalId; private String externalId; private String status; } public class OrderAssigned { @Id private String id; private…
0
votes
0 answers

Spring boot mongodb transaction rollback

Here is the behavior I wish to achieve: @Transactional(rollbackFor = NullPointerException.class) @PostMapping(consumes = {"application/json"}) public Employee createEmployee(@Valid @RequestBody Employee employee) { …
NobleSiks
  • 329
  • 2
  • 4
  • 17
0
votes
0 answers

$unwind in mongodb aggregation (Spring)

I have two collections: Company: { "_id" : "1", "company_code" : "A-111", "code_description" : "BGI", "out_company_code" : "A-111" } Cost center: { "_id" : "2, "company_id" : "1", //Company id "home_cost_center" : "1111", …
Jennifer
  • 107
  • 1
  • 1
  • 5
0
votes
1 answer

Springboot monodb query for to filtered data count

Let say i have userInformation collection below structure userInformation: - name : String - accounts[] : array I need to covert below query into java springboot query. db.userInformation.aggregate([{$match : {"name" : "madhu"}}, {$project:…
Madhuprathap
  • 209
  • 1
  • 3
  • 15
0
votes
1 answer

Spring mongo aggregation filter with $and, $in and $eq conditions

{ "Field1": "ABC", "Field2": [ { "Field3": "ABC1","Field4": "REVIEWED","Field5":"True" }, { "Field3": "ABC2","Field4": "APPROVED","Field5":"True" }, { "Field3": "ABC3","Field4": "REJECTED","Field5":"True" }, { "Field3":…
0
votes
0 answers

spring data - mongoDB - why is it creating multiple objects?

I have code like: public Foo add(String firebaseId) { Foo foo = fooRepository.findByFirebase(firebaseId); if (foo == null) { foo = new Foo(); } foo.setFirebaseId(firebaseId); return fooRepository.save(foo); } public…
user2395365
  • 1,991
  • 4
  • 18
  • 34
0
votes
2 answers

How to use element match inside condition statement of mongodb?

I have two orders Order A: { "_id": "5e0092e725473011f4b4da54", "cash": 400.0, "deliveryFee": 5.0, "paymentOnPickUp" : false, "project": { "_id": "5dd3b4737908cb0cf7b40f84", "name": "Default Instant Deliveries" …
Muhammad Waqas
  • 367
  • 3
  • 13
0
votes
0 answers

Spring Data update mongodb Document with DBRF lazy attribute

I want to update a MongoDB document containing a dbrf lazy attribute using spring data. First of all, I load the existing document, I change the attributes I want and after that, I call @Repository save method, but when I check the document in…
0
votes
1 answer

Why does Spring Data fail on date queries?

I have records in my mongodb which are like this example record. { "_id" : ObjectId("5de6e329bf96cb3f8d253163"), "changedOn" : ISODate("2019-12-03T22:35:21.126Z"), "bappid" : "BAPP0131337", } I have code which is implemented as: public…
Steve Owens
  • 851
  • 1
  • 5
  • 10