All Questions
Tagged with mongodb-query java
631
questions
0
votes
0
answers
16
views
Unable to query using Reference id in morphia 2.4.14 for Reference entity. use of Key<> is deprecated
I have an Entity Book. It contains Language entity. Language entity is stored as DBRef() in database. I need DBRef.
@Entity("Book")
class Book{
@Reference(language_id)
private Language ...
0
votes
0
answers
10
views
Saving limited records per TestCase name in Mongodb
I am working on a framework to save test data for QA test cases in mongodb. I want to save only 20 test data per api request. e.g. if api call is for member summary then I want to limit saving only 20 ...
0
votes
1
answer
95
views
org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate void using constructor NO_CONSTRUCTOR with arguments
I am using spring data mongo for updating one property by the id using mongo repository methods
@Repository
public interface CategoryRepository extends MongoRepository<CategoryEntity,Integer> {
...
1
vote
0
answers
44
views
MongoDB - inserting array object with computed values
i'm implementing a money distribution system with Java 11/ Spring 2.7 and Mongo Atlas 5.0
The structure of my documents is as follows:
{ _id:id_1,
detail:{ amount:500.00, units:50},
users:[
...
0
votes
0
answers
31
views
How to make a query for mongodb using spring to return objects ignoring accent?
I am using Query from mongodb and i am trying to do a search with the attributes "name", "code" and "department". However, I want to ignore upper/lower case, accents and ...
0
votes
1
answer
28
views
How to make a query for mongodb using spring to return objects ordered alphabetically'
I have and class cleed UserModel with the name atribute. And i am trying make a method that return the hole users order alphabetically. My method:
@Query("{ 'name' : { $exists: true }}")
...
0
votes
0
answers
26
views
Mapping Date field in Json to Instant field in Mongo collection in java
I have a java REST endpoint with POST method and saving a document to a collection in MONGO DB
My entity class is as below:
Employee{
@Id
private ObjectId id;
private Instant ...
0
votes
0
answers
123
views
Getting delay in Mongo DB with updateOne
I am updating few fields in a document with java and updates get complete with in 4ms.
I am going to db to fetch same documentjust after the update completes. I am not getting updated documents.
Any ...
0
votes
0
answers
18
views
MongoDB bulk insertion in a collection not updates DB
I have a query regarding MongoDB insertion of a new field . In a collection , there is an array of objects and I want to introduce a new field in the array. Usually, the array size in a record starts ...
0
votes
1
answer
82
views
Spring MongoDB JAVA Sorting Query
I have tried with the below code to short id(string) parameter but it is not sorting correctly.
// Apply sorting
if (sort != null) {
query.with(Sort.by(Sort.Direction.DESC, sort));
OR
// Apply ...
0
votes
1
answer
161
views
updateMany while doing type change in mongoDB using Java
I have a use case to update data in a collection of mongoDB having avg size of 250kb.
Use case: convert datatype from String to Long for a field version.
I would like to do it in efficient way . ...
0
votes
0
answers
56
views
java.lang.AbstractMethodError while implementing mongo db insertOne method in java
I have tried the below.
MongoDB mongoDB = new MongoDB(<connection_string>));
MongoDatabase db = mongoDB.getConnection(\<database_name\>);
MongoCollection\<Document\> collection = db....
0
votes
1
answer
135
views
MongoDB java.lang.IllegalStateException: state should be: open
I have an issue where it says my connection is closed, but I have never closed it. It happens when I try to get a collection. Below is the code needed, the only other time I use MongoDB is to get a ...
0
votes
1
answer
135
views
MappingInstantiationException from MongoDB while trying to update a collection with an abstract class
So I'm having this issue where I'm using a single collection to store different classes that inherit from the same abstract class wrapped in another class. I can insert these records without issue, ...
0
votes
0
answers
31
views
Optimize Aggregate Query MongoDB
I am creating a leaderboard to rank users on multiple different activities. There are roughly 140 different activities that users will need to be ranked on. For brevity, here is an example of what my ...