FAQ Database Discussion Community


MongoDB comparison operators with null

spring,mongodb,null,spring-mongo
In MongoDB I would like to use $gt and $lt comparision operators where the value could be null. When the operators did not work with null, I looked for documentation but found none. In both cases it returned no documents (even though $ne, $gte, and $lte did return documents; meaning...

Spring Mongo convert to document from json string

spring-mongo,spring-mongodb
I have a Mongo collection annotated with @Document and I want the possibility to also get that Java object from a String (JSON) as we're getting these classes pushed into a queue as String. Is there a method in Spring-Data-Mongo which converts from JSON to the actual Document object?...

Search MongoDB Array of Objects where property has same value for more than 1 array element

arrays,mongodb,spring-data,mongodb-query,spring-mongo
I have a Mongo Collection of Products with a Categories field that is an array of objects. { "_id" : ObjectId("XXX"), "title" : "Cool Product", "details" : "Some Details", "categories" : [ { "name" : "Cat1", "isPrimary" : true }, { "isPrimary" : true, "name" : "Cat2" }, { "name"...

MongoDB counts multiple fields

mongodb,spring-data,aggregation-framework,spring-mongo
Here is the input collection : {"itemName" : "A1", "voteType" : "up"} {"itemName" : "A1", "voteType" : "up"} {"itemName" : "A1", "voteType" : "down"} {"itemName" : "A2", "voteType" : "up"} {"itemName" : "A2", "voteType" : "down"} {"itemName" : "A2", "voteType" : "down"} {"itemName" : "A2", "voteType" : "down"} and so...

Mongodb between query in java

java,mongodb,mongodb-query,spring-mongo
i want to read all records that are between col1(value) and col2(value) in mongodb. so i write this code but it not work correctly. How implement this query? my entity is : in my entity i suppose date as long because day or month no important for me. private long...

Is Spring mongoTemplate thread safe?

java,multithreading,thread-safety,spring-mongo
I define this Bean: <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> <constructor-arg name="mongoConverter" ref="mongoConverter" /> </bean> and i instantiate a mongoOprations using this Bean, now i want To know Is Spring mongoTemplate thread safe?...