Questions tagged [spring-mongodb]

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

Do not use this. Use instead.

422 questions
2
votes
2 answers

How to get distance - MongoDB Template Near function

I'm trying to find Near by places. Below code is working fine. But i'm not able to get actual distance of place from my given lat,lng. Criteria criteria = new Criteria("coordinates") .near(new…
2
votes
2 answers

Spring Mongo convert to document from json string

I have a Mongo collection annotated with @Document and I want the possibility to also get that Java object from a String (JSON) as we're getting these classes pushed into a queue as String. Is there a method in Spring-Data-Mongo which converts from…
ianaz
  • 2,490
  • 3
  • 28
  • 37
2
votes
1 answer

updating a multi-embedded data in mongodb

I want to insert into an array-list in an embedded data. I tried several ways but couldn't make it out. My data structure is something like this. The code given here is just a dummy reference to my original data structure Class X{ Integer…
Abhilash Kumar
  • 211
  • 1
  • 9
1
vote
1 answer

Spring Boot deleted enum value deserialization from the database

We are working with MongoDB. We have an object with an attribute which is a set of SubscriptionFeature, where the SubscriptionFeature is an enum. public class Business { ... private Set additionalFeatures; ... } Sometimes we…
1
vote
1 answer

Efficiently Update 1 million documents in the mongodb collection

I need to update around 1-1.5 million documents in a Mongodb collection. Is updateMulti() an efficient way to update the document? I mean will it update the documents in batches internally? import…
1
vote
0 answers

Spring Data MongoDB: Group Aggregation using $ifNull in _id

I need to translate following MongoDb group aggregation to Java code: { $group: { _id: {"startDate": {$ifNull: ["$startDate", null]}, "name": {$ifNull: ["$name", null]}}, "items": { $push: "$$ROOT" …
Mikayel
  • 117
  • 11
1
vote
1 answer

Spring, how do I store java.lang.Class type in mongodb

I'm trying to store java.lang.Class in MongoDb using ReactiveCrudRepository, but I got this following errors. @Document data class Letter( ..., val messageType: Class<*> ) Can't find a codec for class java.lang.Class. I tried implementing my…
1
vote
0 answers

getting object by parameter from nested object mongodb spring data jpa

I have mongodb collection for following documents: @Builder @Data @AllArgsConstructor @NoArgsConstructor @Document public class Account { @Id private String id; @Indexed(unique=true) private String username; …
1
vote
1 answer

How to store date in IST format in MongoDb

Unable to store date in IST format in mongo DB Currently storing date in UTC format during every operations i have to change it into IST format using timezone feature provided by mongo
1
vote
1 answer

Mongo retrieve all values of a specific field including duplicates as list

I have the following data which I am querying on: [ { "_id": 1, "domainName": "test1.com", "hosting": "hostgator.com", "to": "nanjing", "travelDate": "09/06/2022", "trainNumber": 123 }, …
SSM Tariq
  • 13
  • 5
1
vote
0 answers

spring mongodb not saving newly added field

this is my mongo db document classA { private String name; private long elapsedTime; // newly added field } @Document classB extends classA{ private String id; private String owner; } classBRepository.save(classBObject); but newly added…
mr.Nobody
  • 165
  • 7
1
vote
1 answer

Having problem with date comparison in @Query [mongo/springboot]

I am trying to create a custom Query annotation in a MongoRepository. Everything is fine except the date comparison. I need to find all items that were created on a specific day, so I give 2 date objects with the good date and the times fixed to…
benji62f
  • 23
  • 5
1
vote
0 answers

Using @BsonDiscriminator and @BsonProperty with Spring Data Mongo. Is it possible?

I need to start using @Document annotation (org.springframework.data.mongodb.core.mapping.Document) on a class which is used as an entity for mongodb. This class currently uses the @BsonDiscriminator annotation…
NeverSleeps
  • 1,439
  • 1
  • 11
  • 39
1
vote
1 answer

Autowire a Repository to a library project in Spring Boot

I'm working on a Spring Boot multi-module project. I have created separate modules as follows com.foodshop.api - (this is a Spring Boot project, the starting point and both com.foodshop.application and com.foodshop.persistence are added as…
PIKP
  • 753
  • 2
  • 15
  • 24
1
vote
1 answer

MongoTemplate matching referenced object in aggregation

Using MongoTemplate with Criteria to match a Document against a related User as below: var query = new…
luso
  • 2,812
  • 6
  • 35
  • 50