spring-data-mongodb

Error creating bean with name 'personRepository': Invocation of init method failed; nested exception is com.mongodb.util.JSONParseException:

本秂侑毒 提交于 2019-12-25 02:46:33
问题 I am using Spring Data Mongo and using @DBRef in my model class and when I execute the query I get the below error. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dbrefDemoApplication': Unsatisfied dependency expressed through field 'personRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personRepository': Invocation of init method failed; nested exception is com.mongodb

Making Date queries on MongoDB using JSON on SpringDataMongoDB

独自空忆成欢 提交于 2019-12-25 01:39:43
问题 I'm having some trouble making MongoDB Date queries using @Query annotation on SpringDataMongoDB on a project created using JHipster. Since JHipster was used to create the project most of the queries were created using Spring Data query builder mechanism and for more refined queries, instead of using Type-safe Query methods I decided to stick with JHipster's standard configuration and make personalized queries using @Query annotation that allows the creation of MongoDBJSON queries. However, I

Spring Data Mongo cannot find PersistentEntity for Enum

落花浮王杯 提交于 2019-12-25 00:13:27
问题 Edit: I found a related question here, but the only 2 answers contradict each other, and there was not enough information to address my use case. I am trying to use Spring Data Mongo to load records from a collection. One of the fields within those records is an Enum, defined as such: @AllArgsConstructor @Getter @JsonFormat(shape = JsonFormat.Shape.OBJECT) public enum Action { APPROVED("Approved"), SAVED("Saved"), CORRECTED("Corrected"); private String name; @JsonCreator static Action

Spring adding multiple GridFS templates in servlet-context.xml

大憨熊 提交于 2019-12-24 19:27:08
问题 I am new bie to Spring framework. I am planning use to use two gridfs templates for my next project. I want to use two different databases "ProductImage" and "ProfileImage". Depending on image uploaded by user image should be inserted in relevant database. So I am trying to configure my application-context.xml as follows <!-- Mongo GridFs settings --> <!-- Connection to MongoDB server --> <mongo:db-factory host="192.168.1.3" port="27017" dbname="ProfileImages" /> <mongo:mapping-converter id=

MongoDB nested array search using $map

浪子不回头ぞ 提交于 2019-12-24 19:18:43
问题 I have collection which contains nested array. I need to fetch the data based on below condition: empId : 19107 address.country: "AUS" group.primaryGroup.primary:"Y" group.subGroup.primarySubGroup.primary : "Y" Input: { "empId": "19107", "address": [ { "street": "no.12 wilson street", "country":"AUS" }, { "description": "No.32 watson street", "country":"CAN" } ], "mobile": 2387468238, "group": [ { "groupId": 75227, "primaryGroup": [ { "primary": "Y" }, { "primary": "N" } ], "subGroup": [ {

Sliced result using mongo template for the document(not nested)

旧时模样 提交于 2019-12-24 18:13:09
问题 How to retrieve Page result using mongo template I have a scenario like below : final Pageable pageableRequest = PageRequest.of(offset, limit); Criteria criteria = where(""); if (null != type) { criteria = criteria.and("type").is(type); } if (null != revision) { criteria = criteria.and("current_revision_data.data.revision_start").is(revision); } Query query = query(criteria).with(pageableRequest); Page<Invoice> invoices = mongoTemplate.find(query, Invoice.class); Could someone point me how to

Getting error “No serializer found for class org.springframework.data.mongodb.core.convert.DefaultDbRefResolver$LazyLoadingInterceptor”

妖精的绣舞 提交于 2019-12-24 12:25:07
问题 I am using spring data mongodb,after doing lazy loading true i am getting error "No serializer found for class org.springframework.data.mongodb.core.convert.DefaultDbRefResolver$LazyLoadingInterceptor" . My domain class is public class Preference extends BaseEntity { @DBRef(lazy = true) User user; MetadataEnum preferenceType; public User getUser() { return user; } public void setUser(User user) { this.user = user; } public MetadataEnum getPreferenceType() { return preferenceType; } public

How do I combine java.util.Map-based mappings with the Spring Data MongoDB annotations (@Id, @Field, …)?

﹥>﹥吖頭↗ 提交于 2019-12-24 09:12:43
问题 I'm going to store a dynamic document with a certain ID. By the dynamic document I mean a map of strings to objects where I don't really care the exact mapping in order to store documents in arbitrary form. However, I would like those documents to be identified by a certain ID specified programmatically, but I would like to have the ID to be declared with org.springframework.data.annotation.Id . Here is the document mapping I expected to work: @Document(collection = "mappings") public final

how to configure Mongo max thread?

纵然是瞬间 提交于 2019-12-24 03:09:33
问题 I have Mongo injected in to the spring. Everything works well. But when I try to persist data using too many threads , I have such errors: nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Too many threads are already waiting for a connection. Max number of threads (maxWaitQueueSize) of 50 has been exceeded.; nested exception is com.mongodb.MongoWaitQueueFullException: Too many threads are already waiting for a connection. Max number of threads

java.lang.OutOfMemoryError: PermGen space error occurs when MongoTemplate.save(Object objectToSave) in Spring Data MongoDB

只谈情不闲聊 提交于 2019-12-24 03:00:37
问题 Recently in J2EE project, We change spring-data-mongodb's version from 1.7.1.RELEASE to 1.10.12.RELEASE because of safe problems, when invoke MongoTemplate.save(Object objectToSave) method, java.lang.OutOfMemoryError: PermGen space error occurs after about one day after tomcat7 started, but never occurs before spring-data-mongodb's version changed. We try to increase max perm size, but no usefull. We use YourKit tools to investigate jvm classes, then found many classes created with format