Questions tagged [spring-mongodb]

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

Do not use this. Use instead.

422 questions
0
votes
1 answer

How to correctly authenticate with MongoDB when using Repositories in JAVA Spring Framework

I am trying to get Data from a mongoDB with a repository. But when I call the "find" methods, java throws a MongoQueryException and tells me, that find requires authentication. I want to configure my application over a XML file and…
0
votes
1 answer

query using date that stored as string in mongodb in spring mongo data

below is my code - MatchOperation match_Status_Count = new MatchOperation( Criteria.where("date1").gte("2019-3-25T17:34:24.734Z").andOperator( Criteria.where("date1").lte("2019-11-25T17:34:24.734Z") …
0
votes
1 answer

Spring Data with MongoDB - Find by nullable fields

I have a Mongo collection with documents like this: a: { product: 1, country: 2, stock: 1} b: { product: 1, country: 3, stock: 3} c: { product: 2, country: 1, stock: 1} Sometimes I want to get the stock of a product in all countries (so I retrieve…
0
votes
1 answer

Spring Data with ReactiveMongoRepository: generic saving

I would like to save some documents with the value containing a generic. And I constantly receive a StackOferflowError. Here is a fragment of my model class data class MyDocument { val errors: List = emptyList() } SomeError is in…
0
votes
0 answers

Spring boot doesn't create DB from properties

I add this properties to my spring boot application: spring.data.mongodb.host=localhost spring.data.mongodb.port=27017 spring.data.mongodb.database=library and write code: User user = new User(); user.setFirstName("Name"); …
Pavel Petrashov
  • 1,073
  • 1
  • 15
  • 34
0
votes
1 answer

Save dots '.' in key as a field in MongoDB using SpringBoot

I have json data where the key contains dots as '123.456' and value as object. { "models": { "123.456": [{ "key1": "value1", "key2": "value2" }] } } I am getting an…
shashank
  • 379
  • 5
  • 6
  • 15
0
votes
0 answers

Custom @Query - Use @Param or compile with -parameters on JDK 8 error

I having trouble doing a custom query with spring-data-mongo repository. I have the next code: @RestResource public interface RecipeRestRepository extends MongoRepository { @Query(value = "{'title': {$regex : ?0, $options:…
Arturo
  • 1
  • 2
0
votes
0 answers

Simple Mongo DB query is taking very long in Spingboot App

I have a Springboot App that is using MongoDB as the database. One of the collections has a string field and query on that field is taking very long, I am unable to tune it. I have created index but still there is no improvement. Here is my…
rtnyc
  • 145
  • 1
  • 2
  • 10
0
votes
1 answer

Can I switch between two collections under same DB in java spring-boot application?

I have mongodb related code in my java application and can I switch between two collections under same db in java code ? @JsonIgnoreProperties(ignoreUnknown = true) @Document(collection = "collectionA") @QueryEntity public class RepreCase { I want…
0
votes
3 answers

MongoDb: how to search in multiple collections?

I got this structure in my mongodb (2 collections: restaurant and cocktail) restaurant {id=1001, name="Res1", coor=[12.392, 19.123], cocktail=[13, 0, 92]} cocktail {id=13, name="Capiroska"}, {id=167, name="Capirinha"}, {id=92, name="Negroni"},…
Adriano Bellavita
  • 143
  • 1
  • 3
  • 12
0
votes
1 answer

Spring mongodb unwind on nested field

I am trying to run aggregation query where trying to unwind the array which is nested under the key customFields. Structure is like this { "note" : { "customFields" : { "externalAttendees" : [ { …
0
votes
1 answer

Disable Spring Annotations Based on Profile

I'm using Spring 5.1+ with MongoDB. One of my classes is annotated with @Document so it gets picked up by MongoDB, however this is causing the program to fail tests as it times out waiting for the Mongo Service which isn't running. Is there a way to…
SchoolJava101
  • 609
  • 1
  • 5
  • 8
0
votes
1 answer

java mongodb near query

User collection: "userID":"1", "location" : [ 77.667248, 13.0258562 ], "latlong" : { "type" : "point", "coordinates" : [ 77.667248, 13.0258562 ] }, Java query: Query…
nithin
  • 371
  • 9
  • 24
0
votes
1 answer

How build Spring Data Mongo Aggregation Operations using for-loop

The following example works perfectly. MatchOperation matchStage = mongodbConstructorQueryUtils.makeMatchStage(topCriteria); GroupOperation groupStage = Aggregation.group("teamId", "teamName") …
vlarios
  • 31
  • 8
0
votes
1 answer

How to store same document in multiple collection

I am using mongoOperations of Spring Data mongodb to store in MongoDB// mongoOperations.save(reqObj); I need to save the same JSON document which i am getting as rest API response in two collections. @Document(collection="collection_a") public…
user1346346
  • 195
  • 2
  • 16