415 questions
1 vote
1 answer
57 views
Spring Boot (4.0.0) Cannot Connect to MongoDB in Docker Compose Network
I'm trying to connect my Spring Boot application (using spring-boot-starter-data-mongodb) to a MongoDB instance within a shared Docker network managed by docker-compose. The connection is failing, and ...
0 votes
0 answers
72 views
Test tries to connect localhost instead of using embedded mongodb by @DataMongoTest
I have spring app which uses mongoRepository. I want to have an integration to test my repository by using @DataMongoTest. For some reason my test tries to connect localhost for mongo and gets timeout....
1 vote
1 answer
86 views
Get both metrics and traces in Mongodb in Spring
I followed the Spring's documentation to see traces in Mongodb by adding the bean @Bean MongoClientSettingsBuilderCustomizer mongoMetricsSynchronousContextProvider(ObservationRegistry registry) { ...
0 votes
1 answer
79 views
Spring MongoRepository very slow to return entities
First disclaim: I've already seen these topics ==> Spring MongoRepository very slow to convert POJO ==> performance issue on Spring Data Mongodb I clearly have a similar problem, but nothing in ...
0 votes
1 answer
362 views
SpringBoot - MongoDb Connection settings not working
I'm trying to set the timeout settings for Mongo connection in my Springboot app but they are not working as intended. I'm not sure if the issue is with the configuration I have or maybe my test is ...
0 votes
1 answer
186 views
What is the role of @Transactional(readOnly = true) in Spring MongoDB
I understand that when using transactions in MongoDB with the WiredTiger storage engine, the isolation level is fixed to snapshot. If I use @Transactional(readOnly = true), it allows consistent reads ...
0 votes
0 answers
44 views
How to view the complete aggregation statement when using spring data mongodb?
I just started using spring data mongodb aggregation query. fun findRoot(): MarkdownMongoDocument? { val aggregation = Aggregation.newAggregation( MarkdownMongoDocument::class.java, ...
0 votes
0 answers
281 views
Java Mongo DB update Query using aggregation pipeline using $subtract on DateTime field, $match, $project not working
I am using below mongo aggregation pipeline in spring boot java to update document in mongodb. Below is the raw mongo query that works fine when executed directly on mongodb db.lock.aggregate([ {...
0 votes
0 answers
45 views
Spring Mongo how to do query across different datatbase
I need to migrate from single database to two database, and my project have a lookup aggregation like LookupOperation lookupOperation = LookupOperation.newLookup() .from("race")...
0 votes
1 answer
228 views
Upserting a collection of objects in Mongo in a batch in java using Mongotemplate
I have a list of objects of type MyObject, and I wish to insert an object if its not present in the mongo collection, or update if it does. MyObject contains multiple fields, but I want to update if ...
0 votes
1 answer
125 views
MongoRepository saveAll() corrupts ID format
I've found some strange behavior of MongoRepository saveAll(). Here's the entity class and repository: @Document public class Entity { @MongoId private String id; ...
0 votes
1 answer
613 views
Spring boot mongodb : Updating multiple records with custom value using updateMulti
I have a list of records. Each record needs to have 2 fields: temp(temperature in Celcius) and temp_F(temperature in Fahrenheit). temp field is available in mostly all records. But temp_F is missing ...
0 votes
2 answers
113 views
spring mongo how to pass a variable in native mongo aggergation query
I need to do an aggregation query , MatchOperation matchOperation = Aggregation.match(new Criteria("age").is(20)); String lookup = "{$lookup: {from: 'race', localField: 'carId',...
0 votes
1 answer
129 views
Handle Entity annotations for multiple databases (SQL and NoSQL) when only one is active at a time?
I have a school project that needs to support different db at runtime, when only one is selected and is active (a feature to change db after one is selected is not needed). I've been doing some ...
0 votes
1 answer
109 views
How to use groupby min and rertain all field in Spring Mongo aggregation
I want to get by the fastest speed of each car/carId, I have problem in getting/retaining all field when using aggregation in spring mongo . I have check some relatvent in stackoverflow like mongo ...