I am using the following code to remove all the elements from mongoDB collection with a given parent_id
:
final String strQuery = "db.Child.remove({'$query':{'PARENT_ID':'" + parentId + "'}})";
final Query query = entityManager.createNativeQuery(strQuery, Child.class);
query.executeUpdate();
However, I am getting the following exception:
Unexpected Exception
com.mongodb.util.JSONParseException:
db.Child.remove({'$query':{'CHILD_ID':'7313c076-dbaa-4557-b80f-68d040b65d82'}})
If I replace remove
with find
, I get the result back. Dont know what is causing JSON parser error in the aboev mentioned native query.
I am using hibernate-ogm version 4.3 Final with mongo-db 3.2