spring-data-mongodb

@EnableMongoAuditing for MongoDB on Cloud Foundry / mongolab

左心房为你撑大大i 提交于 2019-12-02 06:41:13
My setup works on my local but not when I deploy it to CloudFoundry/mongolab. The config is very similar to the docs . My local spring config @Configuration @Profile("dev") @EnableMongoAuditing @EnableMongoRepositories(basePackages = "com.foo.model") public class SpringMongoConfiguration extends AbstractMongoConfiguration { @Override protected String getDatabaseName() { return "myDb"; } @Override public Mongo mongo() throws Exception { return new MongoClient("localhost"); } @Bean public AuditorAware<User> myAuditorProvider() { return new SpringSecurityAuditorAware(); } } This is the cloud

Spring-Data-Mongodb depedencies not picked by Play-Framework 2.4

浪子不回头ぞ 提交于 2019-12-02 05:48:48
问题 I am using play-framework 2.4 with Spring-Data-Mongodb. But when i compile the project the compile throw an error: [error] /home/james/play-spring-data-mongodb/app/configuration/SpringDataMongoConfiguration.java:10: package org.springframework.data.mongodb.config does not exist [error] org.springframework.data.mongodb.config.AbstractMongoConfiguration [error] /home/james/play-spring-data-mongodb/app/configuration/SpringDataMongoConfiguration.java:11: package org.springframework.data.mongodb

MongoDB Slow query by ID

こ雲淡風輕ζ 提交于 2019-12-02 01:03:00
问题 I recently migrated my MongoDB database from Windows Server to CentOS. The version is 2.4.9. I noticed that I have a slow retrieval of records by _id field! I ran a repair database over the weekend bu that did not solve the problem. I have this method that retrieves records by their IDs (with IN operator) (using spring data mongodb 1.4.1.RELEASE): @Override public Map<String, Record> findAsMapIds( final String[] ids, final ComponentType... comps ) { if( null == ids || 0 == ids.length ) {

Play-Framework 2.4: Use Spring Depedency Injection with Play-Framework Instead of Guice

瘦欲@ 提交于 2019-12-02 00:44:00
问题 I am using Spring-Depedency injection instead of Play-Framework Guice Depedency injection, because of our requirement, we need to use most of the Spring-Modules in our application like Spring-Data-Mongodb etc. But the problem is that, our dependencies are not inject properly in controller like as below: My Configuration: @Configuration @ComponentScan(basePackages={"service", "controllers"}) @EnableMongoRepositories(basePackages="repository") public class SpringDataMongoConfiguration extends

Spring Data-MongoDb Options for aggregation method

我是研究僧i 提交于 2019-12-01 23:22:54
How can i set " allowDiskUse " option in aggregation method in spring data-mongodb framework ? The core aggregation abstraction in Spring Data MongoDB is - as the name suggests - Aggregation . It exposes a fluent API to build up a pipeline using aggregation operations. As of version 1.6.0.M1 the Aggregation class has a ….withOptions(…) method to be used like this: Aggregation aggregation = newAggregation(…) // build up pipeline in here .withOptions(newAggregationOptions().allowDiskUse(true).build()); I found spring data-mongodb to have limited support for the aggregation framework, however you

Spring-Data-Mongodb depedencies not picked by Play-Framework 2.4

吃可爱长大的小学妹 提交于 2019-12-01 23:08:17
I am using play-framework 2.4 with Spring-Data-Mongodb. But when i compile the project the compile throw an error: [error] /home/james/play-spring-data-mongodb/app/configuration/SpringDataMongoConfiguration.java:10: package org.springframework.data.mongodb.config does not exist [error] org.springframework.data.mongodb.config.AbstractMongoConfiguration [error] /home/james/play-spring-data-mongodb/app/configuration/SpringDataMongoConfiguration.java:11: package org.springframework.data.mongodb.repository.config does not exist [error] org.springframework.data.mongodb.repository.config

MongoDB Slow query by ID

与世无争的帅哥 提交于 2019-12-01 21:14:09
I recently migrated my MongoDB database from Windows Server to CentOS. The version is 2.4.9. I noticed that I have a slow retrieval of records by _id field! I ran a repair database over the weekend bu that did not solve the problem. I have this method that retrieves records by their IDs (with IN operator) (using spring data mongodb 1.4.1.RELEASE): @Override public Map<String, Record> findAsMapIds( final String[] ids, final ComponentType... comps ) { if( null == ids || 0 == ids.length ) { return null; } Map<String,Record> result = new HashMap<String,Record>(); final Criteria cr = where("_id")

Sort documents in collections while fetching

强颜欢笑 提交于 2019-12-01 20:57:51
I have a collection called at MongoDB called resource. It has the following documents: { "_id" : "Abb.e", "_class" : "Resource", "resourceEmail" : "test1@test.com" } { "_id" : "Dasd.tt", "_class" : "Resource","resourceEmail" : "test2@test.com" } { "_id" : "Bbb.rr", "_class" : "Resource", "resourceEmail" : "test3@test.com" } At Java code,I list them as follows: MongoOperations mongoOperations = mongoConfiguration.getMongoTemplate(); List<Resource> resourceList = mongoOperations.findAll(Resource.class); return resourceList; How could I fetch these documents sorted by ID ! As you're using Spring

Collection based multitenancy with Spring Data MongoDB

强颜欢笑 提交于 2019-12-01 19:38:43
Our Spring Boot 1.3.3 application persists data on MongoDB (2.6 ou 3.2) using Spring Data MongoDB 1.8.4. We need to support multitenancy. We chose to use "collection based" multitenancy, i.e. each tenant has its own set of collection. For example for the Article entity, the collections are "{tenantName}_articles". Oliver Gierke kindly explained an implementation in Making spring-data-mongodb multi-tenant using for example : @Document(collectionName = "#{tenantProvider.getTenantId()}_articles") This is very nice on paper, but does not seem applicable for real life applications as I found two

Storing a JSON schema in mongodb with spring

我只是一个虾纸丫 提交于 2019-12-01 18:49:45
I am new to Spring data and mongodb. I have a JSON object which represents a JSON Schema and I need to store that in mongodb using spring data. But the issue with JSON schema is the structure of JSON Schema is dynamic; for example below are two valid JSON schema with completely different structure. { "type": "object", "properties": { "name": { "type": "string", "minLength": 10 }, "age": { "type": "integer" } }, "required": [ "name", "age" ] } { "type": "array", "items": { "type": "object", "properties": { "abc": { "type": "boolean" }, "xyz": { "$ref": "#/definitions/" }, "asd": { "type": "null