Newest 'morphia' Questions - Stack Overflow

Questions tagged [morphia]

Morphia is a lightweight type-safe library for mapping Java objects to/from MongoDB.

0
votes
0answers
18 views

MongoDB decimal rounder

I used morphia for MongoDB aggregation to data. but I need to round my aggregation pipeline projection data. my code is aggregationPipeline.project( Projection.projection("_id")....
0
votes
0answers
10 views

Morphia, MongoDB, Q classes and performing updates

I have a large Spring Boot project using MongoDB. Most of the work is done using Spring Data repository classes. These are great. But sometimes I want to do something that isn't easily supported by ...
0
votes
1answer
14 views

How to prevent Morphia from storing empty string in MongoDb

I am trying to Save a Object to MongoDb using morphia which contains fields that have value as empty string. And I don't want those empty string to be saved in mongoDB. For Example : (Json mentioned)...
0
votes
1answer
20 views

Issues in generating Mongo query using Morphia with nested $and and $or criteria

Need to construct a Mongo query dynamically based on expression pattern. But noticed that Morphia query built is producing wrong results even with hardcoded criteria Created a BasicDAO with morphia-1....
0
votes
1answer
18 views

How to Create 10 Character Length Mongo ObjectId's (Like Parse Server)

I'm very curious how to create the 10 char length Mongodb objectIds, i.e. (XlatDx2nYf) that Parse Server uses for its record store. I ask specifically because trying to roll off of a Parse monolith ...
0
votes
0answers
46 views

Mongodb aggregation on multiple fields. How to alias _id field to map to proper object

Below is the mongo db query and respective Java code using morphia. Where I want to alias _id field when I am aggregating with multiple field. This alias will help me in creating proper mapping ...
0
votes
1answer
46 views

MappingException No usable constructor in interface using Morphia

After replacing interface and its implementation I got errors "org.mongodb.morphia.mapping.MappingException: No usable constructor for ***.Project" where Project is interface and "org.mongodb.morphia....
0
votes
1answer
17 views

Is it good practice to pass collection name in Morphia createQuery method?

I usually use this approach while instantiating the query object: Query<Product> query = datastore.createQuery(Product.class); But Morphia allows you to pass the collection name also while ...
0
votes
1answer
27 views

morphia datastore fetch, save, delete query

How to convert below code to List DBCursor users = morphia.datastore().createQuery(User.class).fetch().getCursor(); Also can you give some sample code for delete and save. Thanks.
0
votes
1answer
17 views

Setting value to non DB attribute while fetching documents from Mongo using Morphia

This is one sample document (row) from a collection (table) called product which is in MongoDB: { "_id" : ObjectId("5cb39171528a28f831f"), "seller" : "Product Seller 1", "title" ...
0
votes
2answers
58 views

Reference within MongoDB/Morphia

I found this post where it is discussed if references between documents should be established. I want to annotate my Java class so that references within JSON documents are created: { "id": "3", ...
0
votes
1answer
21 views

Get All Indexes with names , types, properties in Mongo java

Hi I want to retireve all the indexes from Mongo using java. I am using Morphia but am open to using Mongo-Java-Driver as well. I would like to list and iterate over all the indexes , as well as get ...
0
votes
1answer
41 views

MongoDB Morphia use only custom decode converter and default encode converter

I have a problem using Morphia custom converters for mapping embeded documents. In my scenario I have immutable entity with no null-arg constructor. This entity is used as embedded entity in my main ...
0
votes
0answers
21 views

Morphia query with and() expected Criteria but found Object

I'm having trouble using Morphia's or()-Method. I use it as seen in many examples and still I get an Error. This is my code, I'm using Morphia 1.3.2 : Query query = datastore.createQuery(Log.class); ...
0
votes
1answer
17 views

How perform query that delete elements from nested array in MongoDb using Morphia?

I have the following mongoDB object { "_id" : ObjectId("5c3f32a4e17c5739bccb9115"), "name" : "John", "friends" : [ { "name" : "Paul" }, ...
1
vote
1answer
33 views

How to make native mongoDB query in Morphia?

I want to make native MongoDB query in Morphia. Is it possible or Morfia doesn't define this feature?
0
votes
0answers
12 views

Morphia sorting by Date incorrect

I am using morphia framework, and I am unable to find a way to sort a dataset according to date. Morphia uses "order" method to sort the items according to a field in ascending or descending. However ...
0
votes
0answers
28 views

Aggregation by Date

I am trying to agregate by time for statistics. I have object, where i have device_name (PC, Mobile..), time and traffic. public class TrafficRecord extends MongoMorphiaModel { public ObjectId ...
0
votes
1answer
25 views

How to get all _id values from a collection and store them in arraylist using MorphiaQuery in Java Play

I have the following function that should return all the _id values from "Agency" collection: public static List<Agency> findByAgencyIds(List<String> ids){ MorphiaQuery q = Agency.q();...
0
votes
3answers
128 views

Can I use raw query with Morphia?

I have a following query : { query: { "$where" : { this.userName == 'Jack123' } } } Note:- Please don't suggest query.where()
0
votes
1answer
22 views

Getting output of 2 queries in one mongodb call from java morphia

I'm fairly new to mongodb but I was wondering if there's a way by which we can get 2 different results from same mongodb collection in one database call uisng mongo java driver with morphia. I have a ...
0
votes
1answer
100 views

How to prevent no sql injetion when using Morphia with java ee?

I'm using MongoDB with Morphia Object Document Mapper in Java EE. @Override public void removeTrustedDevice(String username, String cookieValue) { MongoConnection conn = MongoConnection....
0
votes
2answers
47 views

How can I connect morphia annotation classes via maven?

I use this dependency: <dependency> <groupId>xyz.morphia.morphia</groupId> <artifactId>morphia</artifactId> <version>1.4.0</version> </...
1
vote
1answer
449 views

Setting Mongodb Connection Pool Options via mongo-java-driver Java API

Using Morphia and mongo-java-driver, I'm connecting to a mongo server: MongoClientOptions.Builder builder = MongoClientOptions.builder(); builder.sslEnabled(true); builder....
0
votes
1answer
54 views

Morphia query for finding an element where a field has a null value

I'm struggling to create a Morphia query (using the typed query class Query<T>) to implement the following: db.getCollection('Order').find({'orderLines.trackingDetails': {$elemMatch: {...
0
votes
0answers
35 views

How to register Morphia with a custom ConstraintValidatorFactory?

I'm using document validation with Morphia. I need to initialize the ConstraintValidators using a non-arg constructors. Generally, we do this by providing a ConstraintValidatorFactory. But with ...
1
vote
3answers
70 views

Serialization: ignore list property with one element that contains empty values

I'm working on a java play framework 2.6 web application with mongoDB. Let's consider this model structure: public class Beneficiary { private Type type; // enum: NGO, PUBLIC_ADMINISTRATION .. ...
0
votes
1answer
24 views

mongodb store Date in different types

I use mongodb-java-driver and morphia to save entity into mongodb, entity has three fields of java.util.Date type: createDate, lastUpdateDate and delDate. I set entity createDate with new Date(), set ...
0
votes
1answer
134 views

How to set a TTL to a document in mongo using morphia?

Currently using the below code in morphia to have a ttl index on the document. @Entity(value = "productDils", noClassnameStored = true) @Indexes( {@Index(fields = {}, options = @IndexOptions(...
1
vote
0answers
34 views

How to write $pull update operation with condition in Morphia

My mongo query looks like this db.profiles.update( { _id: 1 }, { $pull: { votes: { $gte: 6 } } } ) What will be the equivalent of this in Morphia? I see there is removeAll method but that doesn't ...
0
votes
0answers
10 views

Mongo get all keys including the ones of embedded collection

Hi I have a list of embedded entity in mongo. How do I get all the keys for the entire collection in Morphia./Java Say I have class A { int a; List<B> b } class B { int b1; int b2; } ...
0
votes
0answers
40 views

Too many TCP connections to MongoDB

My project uses play framework and have a MorphiaDBHelper which uses scala and singleton pattern. There is DBAccessor class which uses Java and calls MorphiaDBHelper to save information to MongoDB. I ...
0
votes
0answers
19 views

Morphia: Update entire entity based on query

I'm trying use Morphia to do something like this MongoDB upsert var session = {user: "user", session: "session"} db.sessions.update( {user: session.user}, session, {upsert: true}) ...
0
votes
0answers
51 views

Mongodb Morphia Find all documents where birthday is today

We want to find list of all documents in a particular collection where a field named "birthday" is today. I found an answer here using aggregrate query. Require help on how can it be done in morphia?
0
votes
0answers
23 views

Mongo get List of embedded objects together as a list

I am new to MongoDB and am trying to create a query for my schema where I have C object embedded in B, and B object embedded in A. I have a the following schema mentioned : Class A { int a1; ...
0
votes
1answer
49 views

MongoDB CPU usage gets 100%

We have around 100 IoT devices which get connected to the cloud and sends data to cloud every 10 seconds. We tested on 2vcore/4G RAM and 8 vcore/16G RAM. The CPU usage increases to 200% and 800% ...
0
votes
0answers
28 views

MongoDB (mLab) user not authorized on to perform write action using Morphia Client

I am able to insert a document with MongoShell on Mlab mongo instance. But not able to insert a document with Morphia on same. However, the same code is working seamlessly with my local MongoDB ...
1
vote
0answers
95 views

Morphia Mongodb Update in Embedded Array document fails

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 ...
0
votes
1answer
115 views

Spring Boot with Morphia Configuration: BeanCreationException

Me and my project team created a Application with Morphia. Now we want to build a Webservice with Spring which uses the same Entity-Classes and Wrappers. But it seems like Spring tries to instatiate a ...
0
votes
1answer
24 views

Aggregation by date in composed _id Morphia

I need to reproduce an aggregation like this in Morphia db.getCollection('forecasting').aggregate( [ { $match:{ .... } }, { $group: { ...
1
vote
0answers
23 views

Mongo. How to count array of objects from single document? [duplicate]

I tried but I can't to make the query to count e.g. Let's assume that we have a document like this: { "_id" : ObjectId("24926523r3423423423423rr"), "name" : "My super team", "stadium" : "...
0
votes
0answers
133 views

Morphia Mapping Exemption : No usable constructor for org.springframework.security.access.intercept.AbstractSecurityInterceptor

I am using Morphia to map pojos for persistence operations with MongoDB. While the connection too the database is fine, I have the errors as shown in the stacktrace: Exception in thread "main" org....
0
votes
2answers
350 views

Variable 'interface' might not have been initialized

I am trying to build a Morphia and Spring application using a template from another project and I am getting the following error Variable 'assetRepository' might not have been initialized The ...
1
vote
1answer
338 views

Parameter 0 of method init in 'Application' required a bean of type 'package' that could not be found

I am trying to connect Morphia with Java and so tried implementing a project. But, I am getting the following error *************************** APPLICATION FAILED TO START *************************** ...
0
votes
0answers
16 views

Morphia find specific item from embebedd property

I have these entities: @Entity("A") public class A implements Serializable { @Id private String id; @Reference("b") List<B> bList = new ArrayList<B>(); //gets and ...
0
votes
1answer
78 views

Is it possible to force morphia to map the ObjectId to the hex representation?

I am currently working on a kotlin multi project solution. I have one project defining some data classes and defining an api to access a mongodb. The objectId is created automatically. This project ...
0
votes
0answers
40 views

is there a way to make GenericReferenceField work without the _cls attributes add by mongoengine

I have a system that scans data and adds the data to MongoDB with Morphia. on the other side, I have a Flask web application with Mongoengine that reads the data and presents it to a user. this is ...
0
votes
1answer
47 views

MongoDB (or Morphia) conditional reference

I have a MongoDB collection C whose schema contains a manual reference to another collection D, and I'm using Morphia in Java to manage both C and D. D has a boolean field b in its schema, and I ...
0
votes
1answer
189 views

Mongo db upgrade Java driver and morphia version Compatibility

I am trying to upgrade mongodb from 3.0.x to 3.4.x. Currently I am using morphia 1.2.2 (Driver version 3.2.2) and 1.1.1(Driver version is 3.0.2) in two different project which using same database. ...
0
votes
0answers
35 views

Morphia not applying sparse option to my index

I'm trying to use Morphia to interface with MongoDB, and my Morphia entity looks like this: @Entity(some params about storing the entity) public class Entity implements Serializable { <Some ...