Questions tagged [spring-mongodb]

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

Do not use this. Use instead.

422 questions
4
votes
1 answer

Builder pattern when retrieving entity from DB w/ spring boot reactor & mongo

I have the following bean that describes a mongo document, and that uses lombok: @JsonDeserialize(builder = MyClass.MyClassBuilder.class) @Builder(toBuilder = true) @Value public class MyClass { private final String id; @Default …
Tiller
  • 436
  • 1
  • 4
  • 22
4
votes
2 answers

Execute MongoTemplate.aggregate without row retrival

I'm using the Spring Mongo driver to execute a large mongo aggregation statement that will run for a period of time. The output stage of this aggregation writes the output of the aggregation into a new collection. At no point do I need to retrieve…
Max Friederichs
  • 569
  • 3
  • 13
4
votes
0 answers

Extend Mongo Default Config in Spring Boot

I would like extend database mongo configuration about UuidRepresentation STANDARD. I want also use by default all possible 'spring.data.mongodb.*...' properties in *.yml files. I did try this way: @Configuration public class MongoConfig { …
4
votes
1 answer

How to save document with DBRef in mongodb spring-data

I have Spring data repository class that extends MongoRepository. So I'm doing a POST request to create a record that holds several reference fields to refer other documents. The repository interface : @RepositoryRestResource(collectionResourceRel…
GeekySelene
  • 847
  • 3
  • 13
  • 31
4
votes
1 answer

Use $mergeObjects inside ReplaceRoot pipeline stage in Spring MongoDB

i'm looking to reproduce this snipet into Java code : db.getCollection('admins_comptes_client_ceov4').aggregate([ {$lookup: {from: "contrats_ceov4",localField: "CUSTOMERNUMBER",foreignField: "CUSTOMERNUMBER",as: "arrayForeignObject"} {$unwind: {…
Frigg0
  • 125
  • 3
  • 9
4
votes
2 answers

JsonParseException: Invalid JSON input. Position: 9. Character: '.'

I am using MongoDB with Spring Boot 2.0.1.RELEASE. Everything seems to be working fine. I am able to perform CRUD operations properly using MongoRepository. When I use mongodb query in like @Query(value = "{address.city:?0}") public List
Pritam Bohra
  • 3,912
  • 8
  • 41
  • 72
4
votes
1 answer

spring boot - embedded mongodb connection refused

In this example spring boot project I want to test the MongoRepository persistent layer as well as the Service class that uses the repository using an embedded mongodb. However, I get a Connection refused: connect error (java.net.ConnectException),…
tenticon
  • 2,639
  • 4
  • 32
  • 76
4
votes
1 answer

how to get sum of int array field in projection in spring data mongodb

Sample Document from Collection { "_id" : 2, "student" : "Ryan", "homework" : [ 5, 6, 5 ], "quiz" : [ 8, 8 ], "extraCredit" : 8 } Aggregation Query in…
4
votes
1 answer

How to get max field value in collection?

I have collection with name data in mongo db. Document declaration in spring model lools like: @Document(collection = "data") public class DataPoint { @Id private String id; private Long counter; ... } And I want to find max…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
4
votes
1 answer

Spring MongoRepository, where to catch the exception?

I have a Spring project, and a MongoRepository. The MongoRepository is an Interface that extends MongoRepository, just like JPA. If I try to build my project with mvn clean install it runs Spring once. Spring tries to connect to MongoDB which is not…
Randy
  • 9,419
  • 5
  • 39
  • 56
4
votes
1 answer

How use Paging and Sorting in Spring Data mongodb with custom filter?

In Spring Data JPA we have Specifications and can use paging and sorting with specifications. public interface JpaSpecificationExecutor { T findOne(Specification var1); List findAll(Specification var1); Page
Vazgen Torosyan
  • 1,255
  • 1
  • 12
  • 26
4
votes
2 answers

Spring mongodb annotation for 2dsphere index for a geospatial field in java...?

@JsonSerialize @Document(collection = "fence") @CompoundIndexes({ @CompoundIndex(name = "loc_groupId_idx", def = "{ 'loc': 2dsphere, 'groups.groupId': 1 }", unique = false) }) public class…
Sabya
  • 197
  • 4
  • 17
4
votes
1 answer

can we use Ignorecase with whitespace in mongorepository?

Can any one suggest me , How to use "findbynameRegexIgnorecase" in mongorepository? I need to check (regex,Ignorecase) while finding the name itself. spring1.4.2.Release public interface SampleAreaMongoRepository extends MongoRepository
vignesh
  • 83
  • 7
4
votes
1 answer

Caching using @Cacheable with Spring MongoDB integration in spring boot and redis

I was wondering if it's possible to use @Cacheable annotations on the spring data mongo repositories. For example like this: public interface UserRepository extends MongoRepository { @Cacheable("byId") public interface…
demig0d
  • 1,131
  • 1
  • 12
  • 24
4
votes
0 answers

Java spring with mongoDB DBref not fetching the populated data

I am trying to fetch a row in mongo db collection which has an array of object id which is the ObjectID of rows of data in other collection. I want to fetch the populated array of rows of data from ther collection for each record of data from the…
NKMY
  • 67
  • 2
  • 10
1 2
3
28 29