How to custom sort only specific results in Spring MongoDB?

Is it possible to sort only results that matches a condition in Spring Mongo? Let us say I have this data: Color Fruit Amount Orange Orange 23 Red Apple 4 Red Strawberry 66 Yellow Banana 2 I …

MongoTimeoutException: No Server Match – MongoDB Atlas

For a few days now, I can’t connect to any of my MongoDB Databases that are hosted by Altas. I’m always getting a MongoTimeoutException Exception in thread “Thread-9” com.mongodb….

package com.mongodb.client does not exist for a java console program

So here is the back story … I need to make a simple java console project that accesses a MongoDB database and makes some changes to the records within so that another (much larger) program doesn’t …

Can’t modify @Embedded List in Morphia

I have the following Entity: @Entity(“users”) public class UserModel { @Id private ObjectId id; private String userID; private String prefix; private List …

Is it possible to use MongoDb and PostgreSql for same model in Spring boot?

I have built a User management service in which I’m using MongoDb (spring data). I have two models User and Role. package com.userservice.usermanagement.models; import java.util.HashSet; import java….

Mongo aggregate sum of two Strings

I am trying to sum one field in Mongo. If it is an Integer there is no issue, but the problem is that it is String and I get 0 for totalAmount private Integer findRequestAmount(String agentId, String …

Connecting to mongoDB in spring boot causes errors

I want to connect to mongoDB Atlas in a spring boot project, but always Exceptions are thrown. If I use Java without spring boot, everything works fine. The following test project reproduces the …

Aggregation with multiple criteria

I want to perform aggregation using multiple criteria. The problem is that I don’t know how to pass multiple criteria. Do I declare multiple Match operation like below? MatchOperation matchOperation1 …

Insert embeded document without reading whole document – spring, mongo

I have this factory collection : @Document(collection = “factory”) public class Factory { Private List products; } which embeds the Product as products. When I have to add a …

Regex query in spring boot mongoDB on integer

My data schema in mongoDB { id:type(string), itemId:type(int), itemName:type(string) } I want to query on itemId such that if (In my database itemId is (1,2,12 , 13 , 15 27) ) if i search …