如何为聚合查询创建Spring Boot存储库查询?

我想使用mongo db创建spring boot仓库查询。我有收藏名称作为资格

{
    "code": "DEVELOPER",
    "description": "Software Developer",
    "status": "ACTIVE",
    "listItems": [
        {
            "itemId": "JAVA",
            "item": "Java"
        },
        {
            "itemId": "PYTHON",
            "item": "Python"
        },
        {
            "itemId": "PHP",
            "item": "Php"
        },
        {
            "itemId": "JAVASCRIPT",
            "item": "Javascript"
        }
    ],
    "returncode": "00000",
    "message": "Data Available"
}

我尝试了以下查询来获取与此模式ja匹配的任何内容,

db.employee.aggregate([{$match:{"code" : "DEVELOPER"}},
{$project : {listItems:{$filter:{
    input: "$listItems",
               as: "listItems",
               cond: { $regexMatch:{
                        input:"$$listItems.item",
                        regex: /ja/i}  }
}}}}])

我得到的确切答案是,

{
    "code": "DEVELOPER",
    "description": "Software Developer",
    "status": "ACTIVE",
    "listItems": [
        {
            "itemId": "JAVA",
            "item": "Java"
        },
        {
            "itemId": "JAVASCRIPT",
            "item": "Javascript"
        }
    ],
    "returncode": "00000",
    "message": "Data Available"
}

但是当我使用mongotemplate在Java中尝试并得到NULL指针异常并且没有得到任何输出时

public List<ListValue> findAllByCode(String code,String item) {
           Query query = new Query();
           query.addCriteria(Criteria.where("code").is(code).and("listItems.item").regex("^" + item + "$", "i"));

           return mongoTemplate.find(query, ListValue.class);
        }