'wanted to execute mongo native Query in Java using mongotemplate

I wanted to execute bewlo native mongoQuery in java,

    String jsonCommand = "db.testCollection1.insertMany(db.testCollection2.aggregate([{'$group':{'_id':'$something_id','persons':{$push:{
    'personId':'$personId'
    }}}},
    {'$project':{
    'something_id':'$_id',
    'persons':'$persons'
    }}]).toArray())";


    mongoTemplate.executeCommand(jsonCommand);

But i am getting

json reader was expecting a value but found db



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source