morphia

findAll fails after play morphia is reinitialised

放肆的年华 提交于 2019-12-25 07:49:24
问题 I have the following class which is persisted into a mongodb using morphia in a play! application. The class resides in a module which is a dependency of another play! application. Its configuration is read from a file and persisted into the db on initial load (if its not already in the db) and then subsequent requests use the db version. @Entity public class Page extends Model { @Id public Long navigationId; // etc ... } The initial load and subsequent query access works ok and i can see the

Mongodb count with queries have poor performance

十年热恋 提交于 2019-12-25 05:57:08
问题 Counting the number of records in a collection that is matched by a query even on an indexed field takes too much time. For example lets say there is a collection consists of 10000 records, and there is an index on the creationDate field of this collection. Getting the last ten records from the collection is faster than counting the number of records created on the last day. It takes more than 5 seconds, sometimes even up to 70 seconds to return the result of the count query. Do you have any

Mongodb count with queries have poor performance

断了今生、忘了曾经 提交于 2019-12-25 05:57:03
问题 Counting the number of records in a collection that is matched by a query even on an indexed field takes too much time. For example lets say there is a collection consists of 10000 records, and there is an index on the creationDate field of this collection. Getting the last ten records from the collection is faster than counting the number of records created on the last day. It takes more than 5 seconds, sometimes even up to 70 seconds to return the result of the count query. Do you have any

Reading BigDecimal with Morphia

廉价感情. 提交于 2019-12-25 03:57:11
问题 I have a POJO that uses BigDecimal. When I save the object to morphia, it is clear the value is saved as a string. But if I modify the database from the javascript shell to have some decimal number value, The try to read the object using the morphia class, It fails with the following error: For example: @Entity(value = "table_name", noClassnameStored = true) public class Advertisement implements Table { BigDecimal value; } java.lang.ArrayStoreException at java.lang.System.arraycopy(Native

How to use MongoDB Morphia on Android?

爷,独闯天下 提交于 2019-12-25 02:19:13
问题 I am trying to use morphia on an Android application to interact with a MongoDB instance. Gradle dependency: implementation 'org.mongodb.morphia:morphia:1.3.2' When instantiating Morphia Morphia morphia = new Morphia(); I get this error: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.dibu2018.futbol, PID: 5085 java.lang.ExceptionInInitializerError at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:453) at java.lang.Class.forName(Class.java:378)

field access for lists of objects in a class via morphia in mongodb

谁说我不能喝 提交于 2019-12-25 01:35:10
问题 I have some problems while implementing filters in mongodb using morphia POJO mapper. In my class (for example SampleClass ), when i try to access the fields of an @Entity class (in our case it's Person ), I find the field access works fine, using dot notation for general fields like int, string, maps or direct embedded objects. The issue is I could not understand how it works for the case of a "List of Objects" referenced in the Person class. (Assume here, a person can have many addresses,

Morphia Mongodb Update in Embedded Array document fails

笑着哭i 提交于 2019-12-24 09:18:46
问题 I am new to Morphia and am trying to update a field in embedded document. This is the current structure class A { List<B> BList; } class B { String field; } So My structure looks like the following in MongoDb : { "_id" : ObjectId("5bab8be0032945f6e9f91d98"), "className" : "com.abc.A", "BList" : [ { "B" : { "field" : "text" } } } Now I want to update B.field for all the matching queries. I created the following UpdateOperations UpdateOperations updateOps = datastore.createUpdateOperations(A

Can't find a codec for class , Morphia , Spring

这一生的挚爱 提交于 2019-12-24 09:16:46
问题 Posting JSON towards tomcat running Spring BOOT. Mapping requests to update Mongo via Morphia Getting Error : "status":500,"error":"Internal Server Error","exception":"org.bson.codecs.configuration.CodecConfigurationException","message":"Can't find a codec for class se.preffo.model.ProfileAccess. Somehow it is not knowing how to create the Object ProfileAccess ProfileClass package se.preffo.model; import java.util.List; import org.bson.types.ObjectId; import org.mongodb.morphia.annotations.*;

com.mongodb.MongoException$Network Caused by: java.net.SocketTimeoutException: Read timed out

会有一股神秘感。 提交于 2019-12-24 05:58:42
问题 When I insert documents into Mongo-DB using morphia, it always occur com.mongodb.MongoException$Network: Write operation to server exceptions, maybe interval of one minute The follow is the stack info: com.mongodb.MongoException$Network: Write operation to server at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:153) at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:115) at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:327) at com.mongodb.DBCollection.update(DBCollection

Morphia MappingException: a type could not be found for field null.null

痴心易碎 提交于 2019-12-24 03:28:08
问题 I'm trying to upgrade Morphia from .108 to 1.01 in some code I've inherited. There's a class that looks like: @Entity(value="audit", noClassnameStored=true) public class AuditEntry<T> { @Id private ObjectId id; @Embedded private Delta<T> delta; public ObjectId getId() { return id; } public void setId(ObjectId id) { this.id = id; } public Delta<T> getDelta() { return this.delta; } public void setDelta(Delta<T> delta) { this.delta = delta; } } Then the embedded delta class: @Embedded public