Questions tagged [mongotemplate]

Part of Spring Data project which provides consistent Spring-based programming model for new datastores while retaining store-specific features and capabilities.

406 questions
23
votes
13 answers

MongoTemplate upsert - easy way to make Update from pojo (which user has editted)?

Here is a simple pojo: public class Description { private String code; private String name; private String norwegian; private String english; } And please see the following code to apply an upsert to MongoDb via spring…
vikingsteve
  • 38,481
  • 23
  • 112
  • 156
14
votes
2 answers

MongoTemplate Criteria Query

I'm generating a complicated Mongo query depending on multiple parameters. One of criterion that I want to make with Criteria helper class is: {"field1": {$exists: true, $ne: false}} I tried to make it…
Aeteros
  • 643
  • 1
  • 10
  • 24
14
votes
3 answers

MongoTemplate pull subdocument

I need to pull a subdocument in MongoTemplate but cannot figure out how to do it. My saved document is: { "_id" : "FooUser", "_class" : "com.domain.User", "tests" : [ { "variant" : { "_id" : "C", …
fernandospr
  • 2,976
  • 2
  • 22
  • 43
11
votes
1 answer

How to upload and retrieve file in mongodb in spring boot application without using GridFSTemplate?

I want to upload files and retrieve them from mongodb in spring boot application. But I don't want to use GridFSTemplate because my file size will not be greater than 16 MB. I am not choosing GridFSTemplate because none of the requirements mentioned…
Sarvesh
  • 551
  • 1
  • 10
  • 25
11
votes
2 answers

Spring Boot with MongoTemplate

I am new to Spring Boot and MongoDb. Trying some examples with Mongo Repositories and Spring Boot. But after going through some of the documents found that Mongo Template is will be a better option. Unable to get a proper Spring Boot with Mongo…
umesh
  • 312
  • 3
  • 4
  • 15
10
votes
1 answer

Spring data mongodb remove a property from a document using MongoTemplate

I have a document as shown below { "_id" : ObjectId("5864ddd8e38112fd70b89893"), "_class" : "com.apic.models.UserReg", "name" : "xxx", "email" : "xxx.xxx@xxx.com" "activationToken" : "fe8376ea2dbdf61ebc" } How can I remove the…
BiJ
  • 1,639
  • 5
  • 24
  • 55
10
votes
3 answers

While saving a collection MongoDB is creating Index name which is too long and exceeds 127 bytes limit. How to solve this. can i disable indexing?

com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "createdCollectionAutomatically" : true , "numIndexesBefore" : 1 , "ok" : 0.0 , "errmsg" : "namespace name generated from index name…
shashidhar kache
  • 131
  • 1
  • 1
  • 3
10
votes
1 answer

Find elements in a collection where an element has a field which is a list and a given value must belong to the list

I would like to query the objects in my collection such as a given value must belong to the values in the stringArray stringArray is the name of the field for each Obejct that contains a list of Strings the strucutre of my collection in mongodb…
Makoto
  • 765
  • 2
  • 17
  • 45
9
votes
3 answers

Error creating bean with name 'mongoTemplate' while connecting mongodb through Spring

I am trying to connect mongoDb with Spring's mongoTemplate. I also tried changing version of 'spring-data-mongodb' from 1.7.2.RELEASE to 1.8.2.RELEASE, but even that didn't work. Below is my code as used in the project. Here's my pom.xml
anukuls
  • 285
  • 2
  • 5
  • 16
8
votes
2 answers

Spring MongoTemplate - Mapping aggregation result to collections (e.g. List and Map)

aggregate method of MongoTemplate returns AggregationResults, where T being the class that corresponds to mongo collection. Sometimes, we only want the single (say property abc) or a couple of properties (pqr and xyz) from that collection…
Harish
  • 169
  • 1
  • 2
  • 7
8
votes
3 answers

create indexes for search using MongoTemplate?

how we can create Indexes for the following query using MongoTemplate? I am referring to site http://docs.mongodb.org/v2.4/tutorial/search-for-text/ they've not given any details about how we can create Indexes using…
user5268786
7
votes
5 answers

Java MongoDB save multiple documents at once

I Have a list of updated objects/documents i need save all the objects in the list at once. I saw save() in MongoTemplate but it can take single document at a time. Is there any way to save multiple documents at once or i need to call save in loop…
6
votes
1 answer

MongoTemplate Query to find Objects with child array size greater than

I need to write a Query which can find objects in DB whose child array size is greater than something. My Object looks like: { "_id" : ObjectId("sbg8732god78"), "studentIds" : [ "d3782gdo", "d8o3g7" ] ... } I need to find all objects…
Shubham A.
  • 2,446
  • 4
  • 36
  • 68
6
votes
5 answers

Spring data mongo bulk update

Bulk updates are supported from spring-data-mongodb from 1.9.0.RELEASE. BulkOperations ops = template.bulkOps(BulkMode.UNORDERED, Match.class); for (User user : users) { Update update = new Update(); ... …
Shuying Zhang
  • 61
  • 1
  • 1
  • 3
5
votes
0 answers

How to update MongoDB collection field using another field using MongoTemplate in spring-boot

I need a field value to be updated using another field using the mongo template in spring-boot. I am aware of how this can be done using MongoDB queries. But could not figure out a way of doing this using MongoTemplate from the database level…
Sameera Manorathna
  • 558
  • 12
  • 26
1
2 3
27 28