I am trying the following query but hibernate ogm is giving wrong result.
db.mycollection.find({“cav_id” :3},{_id:0}).count()
mongodb shell output is
1
while hibernate ogm’s output
3
This is the result after executing this
entityManager.createNativeQuery(queryModel.getQuery()).getResultList();
where queryModel.getQuery() = db.mycollection.find({"cav_id" :3},{_id:0}).count()
Output :
[3.0, 24.0, 45000.0, Document{{House_No=103.0, Street_No=45.0, Block=F, Contact=Document{{first_cell=1.23458679E8, second_cell=9.87165243E8, third_cell=6.54912873E8}}}}]
hibernate is returning the object after find operation but not executing the count() operation.
This is the output from Mongo Shell
db.mycollection.find({“cav_id” :3},{_id:0});
{ “cav_id” : 3, “age” : 24, “salary” : 45000, “Address” : { “House_No” : 103, “Street_No” : 45, “Block” : “F”, “Contact” : { “first_cell” : 123458679, “second_cell” : 987165243, “third_cell” : 654912873 } } }
db.mycollection.find({“cav_id” :3},{_id:0}).count()
1