spring-data-mongodb Questions

3

I currently have a query that returns all the documents in a collection using the findAll() method of MongoTemplate. I want to sort these results, but do not see any way to do so. I see that I can ...
Particulate asked 22/9, 2015 at 22:13

1

Can someone tell me how do I configure spring data mongoDB in such a way that it does not create a new collection(if it does not exist) but throws an exception while inserting a document?
Haemolysin asked 25/10, 2017 at 4:45

2

Solved

I just started developing some app in Java with spring-data-mongodb and came across some issue that I haven't been able to solve: Have a couple of document beans like this: @Document(collection="...
Hipster asked 15/2, 2013 at 1:23

4

Solved

I have the following object structure: @Document(collection = "user") @TypeAlias("user") public class User { @Id private ObjectId id; private Contact info = new Contact(); } and here is the C...
Kierkegaard asked 10/3, 2014 at 11:26

4

Solved

Scenario: I want to start both Mongo and Mongo-Express from same docker-compose. I have no issue starting only mongodb from docker-compose. The issue raises when I try to link Mongo-Express to Mon...

7

Solved

I'm using Spring Data for Mongo on an existing database. The previous application used plain strings for ids instead of ObjectId. My problem is that Spring Data insists on converting the strings t...
Nystagmus asked 15/1, 2013 at 0:17

2

Solved

To create an index for a collection (as documented here https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/) one can use something like the following: mongoTemplate.indexOps(Pe...
Ovida asked 1/11, 2017 at 13:15

7

Solved

I have made an experiment... one common entity for two Spring data's repositories: - JPA - MongoDB first of all I' using following libraries versions: spring-data-jpa : 1.7.0.RELEASE spring-data-...
Bartolemo asked 26/10, 2014 at 15:4

3

I am working on an application using Spring Data MongoDB. I would like to create a compound index on one of my models. I have added a @CompoundIndex annotation at the top like so: @Document @Compo...
Shorts asked 11/6, 2015 at 7:30

1

Solved

In a Spring Boot project, I use annotations like @CreatedDate to save information about dates when the corresponding documents are created / updated. ZonedDateTime is used throughout the project, s...
Fascinating asked 17/4, 2018 at 12:45

5

I need to know the equivalent code in spring data mongo db to the code below:- db.inventory.find( { qty: { $all: [ { "$elemMatch" : { size: "M", num: { $gt: 50} } }, { "$elemMatch" : { num : 10...
Pulley asked 5/3, 2015 at 9:59

3

I'm using Spring Data Mongodb library and I don't know to find by @Query an element in two collections joined with @DBRef, like this: User: @Document public class User { @Id @JsonSerialize(using...
Baras asked 25/4, 2016 at 6:15

6

In my Spring Boot web application I use MongoDB to store data. In the application I access the database using interfaces that extend MongoRepository. How do I set up a unit test for such a reposit...
Tommyetommyrot asked 12/8, 2015 at 16:25

2

Solved

I am developing Test cases for the Spring Data Mongo Services. org.mockito.exceptions.misusing.WrongTypeOfReturnValue: Optional cannot be returned by stream() stream() should return Stream *** I...
Unstrung asked 14/5, 2019 at 17:8

2

Solved

I write some code.I want to make questionId field in BaseQuestion Class as Autogenerated.Any solution for that? I am not using jpa jar.so i can't use @Generatedvalue annotation.So how we show here ...
Over asked 6/4, 2016 at 10:51

6

I want to implement a delete method which deletes all the documents in a collection. I am using mongo db with Spring Data.This could be done using db.myCollection.remove({}) in Mongo shell. But I w...
Coatbridge asked 28/2, 2018 at 11:32

3

Solved

Assume that I have such entities like the following: @Document(collection = "doc_a") public class A { @Field("id") private Integer id; @Field("b") private Collection<B> b; ... } pub...
Anabolism asked 26/12, 2012 at 13:0

2

I am using spring-data-mongodb. I want to query database by passing some optional parameter in my query. I have a domain class. public class Doc { @Id private String id; private String type...
Swedenborgianism asked 15/6, 2015 at 9:0

3

Solved

I am using spring-data mongo with the JSON based query methods, and am unsure how to allow optional parameters in a search query. For instance - say I had the following function @Query("{ 'name'...
Ginglymus asked 23/7, 2012 at 13:25

7

How can we select specific fields in Spring Data Mongo. I tried the following but I got cast exception from Foo to String. Using @Query @Query(value="{path : ?0}", fields="{path : 0}") String fin...
Felishafelita asked 20/8, 2015 at 3:12

3

I have been trying to follow the instructions in the link below to try to add an automatically configured Embedded MongoDB Instance for Cucumber Integration testing. This is currently not working, ...

3

Solved

I'm trying to understand reactive part of spring 5. I have created simple rest endpoint for finding all entities using spring web-flux and spring data reactive (mongo) but don't see any way how to ...

7

Solved

I am using the latest spring-data-mongodb (1.1.0.M2) and the latest Mongo Driver (2.9.0-RC1). I have a situation where I have multiple clients connecting to my application and I want to give each o...
Crane asked 22/8, 2012 at 17:47

2

I've two entities Person, Employee and Employee1. I want to implement entities inheritance in Spring Data MongoDB. Like in Spring Data JPA, what are the equivalent annotations for @Inheritance and ...
Britisher asked 25/4, 2017 at 23:48

2

Solved

I am unable to perform update operation. Using spring boot with mongodb 3.4. On trying to save I am receiving the following kind of error : WriteError{code=11000, message='E11000 duplicate key err...
Allianora asked 4/3, 2022 at 7:14

© 2022 - 2025 — McMap. All rights reserved.