morphia

Morphia List<Map<String,Object>>> return Embedded element isn't a DBObject on find operation

拟墨画扇 提交于 2019-12-10 11:34:37
问题 I have tried to do something like this: package org.dnylabs.kosh.data; import java.net.UnknownHostException; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import com.google.code.morphia.Datastore; import com.google.code.morphia.Morphia; import com.google.code.morphia.annotations.Entity; import com.google.code.morphia.annotations.Id; import com.mongodb.Mongo; import com.mongodb.MongoException; @Entity public class Temp { @Id String _id;

MongoDB schema design - finding the last X comments across all blog posts filtered by user

会有一股神秘感。 提交于 2019-12-08 19:10:35
I am trying to reproduce the classic blog schema of one Post to many Comment s using Morphia and the Play Framework. My schema in Mongo is: { "_id" : ObjectId("4d941c960c68c4e20d6a9abf"), "className" : "models.Post", "title" : "An amazing blog post", "comments" : [ { "commentDate" : NumberLong("1301552278491"), "commenter" : { "$ref" : "SiteUser", "$id" : ObjectId("4d941c960c68c4e20c6a9abf") }, "comment" : "What a blog post!" }, { "commentDate" : NumberLong("1301552278492"), "commenter" : { "$ref" : "SiteUser", "$id" : ObjectId("4d941c960c68c4e20c6a9abf") }, "comment" : "This is another

Complex AND-OR query in Morphia

浪尽此生 提交于 2019-12-08 17:28:28
问题 I've been trying to combine the and() and or() methods of the Query interface to create a set of conditions where there are 2 lists of criteria, and at least one from each must be satisfied. I read this discussion and have been trying to use the Query.and() to combine my two $or clauses. Essentially, I'm trying to say: Criteria[] arrayA; Criteria[] arrayB; // Programatically populate both arrays Query q = dao.createQuery().and( q.or(arrayA), q.or(arrayB) ); I'm using arrays of criteria

MongoDb and morphia password and username

笑着哭i 提交于 2019-12-08 05:48:57
问题 playing around with this and cannot get a grip on how to connect with password. In MongoDb it's quite easy to understand but when i use morphia it's not so quite obvious because documentation is minimal or i missed it. I already have a Collection with 5 documents. Can i apply a user/pass on that one? How can i modify this code so logging uses a username and password? Took the code from this post (Thanks @Lennart Koopmann) MongoDB Java driver tutorial public final class MongoConnectionManager

How to fix this Morphia mapping issue??? ---> WARNING [org.mongodb.morphia.mapping.DefaultCreator] - Class not found defined in dbObj:

拜拜、爱过 提交于 2019-12-08 03:51:02
问题 So here goes the problem leading to the question... I have this javaEE application running on jBoss using MongoDB database. I use Morphia to communicate with mongo... The application has the following basic program components; @EntityListeners(RootEntityListener.class) public class RootEntity { @Id protected ObjectId id; @Indexed protected Long uid; @Indexed protected boolean active; ... } @Entity public class User extends RootEntity { ... } @Entity public class News extends RootEntity { ...

MongoDB - Index not being used when sorting and limiting on ranged query

送分小仙女□ 提交于 2019-12-08 02:37:51
问题 I'm trying to get a sorted list of items using a ranged query on a collection containing bulletin-board data. The data structure of a "thread" document is: { "_id" : ObjectId("5a779b47f4fa72412126526a"), "title" : "necessitatibus tincidunt libris assueverit", "content" : "Corrumpitvenenatis cubilia adipiscing sollicitudin", "flagged" : false, "locked" : false, "sticky" : false, "lastPostAt" : ISODate("2018-02-05T06:35:24.656Z"), "postCount" : 42, "user" : ObjectId("5a779b46f4fa72412126525a"),

Mongo connection leak with morphia

情到浓时终转凉″ 提交于 2019-12-07 17:31:31
问题 I have a Servlet with static Mongo = new Mongo() and Morphia morphia = new Morphia() objects. Each time GET is invoked, I do the following: doGet(...){ ... datastore = morphia.createDatastore(mongo, dbName); ... } I don't close datastore , because there is no close method. Each time i invoke the servlet, number of used connections in mongo grow: { "current" : 113, "available" : 706, "totalCreated" : NumberLong(122) } > db.serverStatus().connections { "current" : 115, "available" : 704,

In Morphia how can i update one embedded Object inside an ArrayList

本秂侑毒 提交于 2019-12-07 12:23:43
问题 Really new to Using Mongodb with Morphia and see many advanced answers how to do this. I want to do it simple if it's possible and I have this @Embedded Object called fileObjects that contains Files Objects. I Cannot update the fields inside the Files . I want to update only one field f.ex the String fileHash . @Entity public class BatchData { @Id private ObjectId id; @Embedded public ArrayList<Files> fileObjects = new ArrayList<Files>(); } UPDATE.. Reading the wiki at Morphia Updating dont

MongoDB / Morphia saves technical id as ObjectId although it's a String in Java

痞子三分冷 提交于 2019-12-07 11:45:28
问题 I've got two kinds of documents in my MongoDB: clients and codes. Each code refers to one client. Clients have to be stored explicitly by an administrator, therefore I have to store them separate and cannot put them into a code document. code -> client Now MongoDB / Morphia saves technical ids of clients as ObjectId, whereas codes refer to clients with a technical id of type String. I am able to search a code by a given client id, but at the runtime I'll get a error message, because Morphia

Mongo Java drivers & mappers performances

一笑奈何 提交于 2019-12-07 08:38:39
问题 Mongo in Java can be used with several tools: the 10gen official driver an alternative async Java driver a mapper — a library built on top of a driver — Morphia, Jongo... ( see complete list ) Is there some benchmarks comparing mappers to drivers performances and one versus each others? 回答1: Unfortunately, there are no benchmarks that I am aware of. The driver home page is here (but I'm guessing that you probably know that) and the Java Language Center containing all information related to