spring-data-mongodb

'Couldn't find PersistentEntity for type class' exception in Spring boot MongoRepository

对着背影说爱祢 提交于 2019-12-12 12:30:28
问题 In here I have configured two databases in mongodb. As described in this tutorial (link). So basically I override the MongoDataAutoConfiguration and MongoProperties implementations. The property yml file : spring: autoconfigure: exclude: org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration mongodb: primary: host: 127.0.0.1 port: 27017 database: db_admin_crm secondary: host: 127.0.0.1 port: 27017 database: lead_forms MultipleMongoProperties class : @Data @ConfigurationProperties

Spring MongoDB + QueryDSL query by @DBRef related object

吃可爱长大的小学妹 提交于 2019-12-12 09:40:00
问题 I am using spring-data-mongodb and querydsl-mongodb to perform more flexible queries. My application has users and orders. An user can have multiple orders, so my models looks like this: public class User { @Id private String id; private String username; //getters and setters } public class Order { @Id private String id; @DBRef private User user; //getters and setters } As you can see, there is an has-many relationship between users and orders. Each order is assigned to an user, and the user

How to use updateOption with arrayFilters in spring-data mongodb?

只愿长相守 提交于 2019-12-12 08:56:11
问题 I have a document as shown below in Mongodb: Now, I want to go to a document based on specific " _id " and for that document, want to go to "schedule" list in which for the few specific dates (not only one date, but more than one), I want to update the status as "BOOKED".I went through this link, How to apply update using Filtered positional operator with arrayFilters but in MongoTemplate class, updateMulti method does NOT take the updateOption parameter. Can someone please help Me out.

Spring Mongodb - Insert Nested document?

大憨熊 提交于 2019-12-12 06:21:58
问题 I have the following classes @Document public class PersonWrapper { @Id private ObjectId _Id; @DBRef private Person person // Getters and setters removed for brevity. } public class Person { @Id private ObjectId _Id; private String name; // Getters and setters removed for brevity. } And - I have the following MongoReposityClass... public interface PersonWrapperRepository extends MongoRepository<Person, String> { Person findByPerson_name(String name); } Showing the repository class may have

How to update a inner/embedded document in a mongodb using mongotemplate

a 夏天 提交于 2019-12-12 04:54:32
问题 Can some one help me to write a code to update "coordinates". I was able to update the address but not the coordinates. { "_id": "2c9080e54b4ee7ac014b4ee8e5100000", "_class": "com.myparking.dataservice.mongodb.documents.ParkingSiteDocument", "address": { "streetAddress": "bellandur", "locality": "ORR", "region": "bangalore", "country": "india", "postalCode": "560102" }, "geoLocation": { "coordinates": [ 12.934292, 77.680215 ], "type": "Point" } } My code goes like this: When I update the

How do I update Map field without retrieve it in a MongoDB document?

浪子不回头ぞ 提交于 2019-12-12 04:46:54
问题 I have a document with an Map field, similar to this: { "_id" : "....", "metaMap" : { "k1":"v1", "k2":"v2", //... } } How can I update(add or replace some key-value pair) the metaMap field without retrieve the whole map? For example,when update with the parameter {"k2":"new-v2","k3":"v3"} the document become like this: { "_id" : "....", "metaMap" : { "k1":"v1", "k2":"new-v2", "k3":"v3", //... } } I'm using spring-data-mongodb. 回答1: DBObject queryObject = new BasicDBObject("someUniqueField",

spring-data with neo4j + mongo version conflicts

折月煮酒 提交于 2019-12-12 02:42:37
问题 In my spring application I am working with Neo4j DB via spring-data project. I want to add mongo db as another data store to my application. It seems that there some conflictions while trying to work with these two data stores together. my pom - only the relevant dependencies: <spring.version>3.1.2.RELEASE</spring.version> <spring.data.mongo.version>1.0.4.RELEASE</spring.data.mongo.version> <neo4j.version>1.8.RC1</neo4j.version> <spring-data-neo4j.version>2.1.0.RC4</spring-data-neo4j.version>

Spring Data Mongo Query Field parameters

主宰稳场 提交于 2019-12-12 01:06:46
问题 I'm playing with Spring Data Mongo Query and wondering about the field property parameters. Here is the example that I got from the documentation: public interface PersonRepository extends MongoRepository<Person, String> @Query(value="{ 'firstname' : ?0 }", fields="{ 'firstname' : 1, 'lastname' : 1}") List<Person> findByThePersonsFirstname(String firstname); } The question is: What is the meaning of 1 in { 'firstname' : 1, 'lastname' : 1} ? 回答1: 1 means that both 'firstname' and 'lastname'

Avoid saving data in spring data rest in handleBeforeSave

浪尽此生 提交于 2019-12-11 23:52:48
问题 I am using @RepositoryRestResource for Mongo Repositories. I want to do some pre-save check and if those checks are not meeting the requirements, I want to abandon the save operation. I tried : @HandleBeforeSave public void handleBeforeSave(CallLog callLog) throws InternalServerException { CallLog log = callRepository.findOne(callLog.getConferenceId()); if (log != null && (callLog.getStatus().equals(Constants.CALL_IN_PROGRESS) || callLog .getStatus().equals(Constants.CALL_DROPPED))) { if

How configuring access to a sharded collection in spring-data for mongo?

谁说我不能喝 提交于 2019-12-11 19:17:41
问题 I was wondering how to configure sharding in a spring config file. I took a look at this post http://krams915.blogspot.com.es/2012/02/mongodb-replica-sets-with-spring-data_9536.html and seems to work for a single replica set. But in case you have a sharding envrionment with several replica set, mongos instances, ..., is spring-data currently supporting this? Regards. 来源: https://stackoverflow.com/questions/20647829/how-configuring-access-to-a-sharded-collection-in-spring-data-for-mongo