Java Spring MongoDB获取特定月份的条目

Java Spring MongoDB获取特定月份的条目,java,spring,mongodb,Java,Spring,Mongodb,我有一个包含ISODate列(生日)的集合,我的任务是获取集合中所有在生日属性中具有特殊月份的行。我正在使用spring和java来查询mongodb,我已经尝试使用聚合。。结果应该是一个列表,其中包含与给定月份匹配的所有条目。因此,我认为聚合不是正确的方法。。。第一个想法是下面的代码,但它给了我一个null指针异常 Aggregation agg = newAggregation(Customer.class, project("customerBirthday").a

我有一个包含ISODate列(生日)的集合,我的任务是获取集合中所有在生日属性中具有特殊月份的行。我正在使用spring和java来查询mongodb,我已经尝试使用聚合。。结果应该是一个列表,其中包含与给定月份匹配的所有条目。因此,我认为聚合不是正确的方法。。。第一个想法是下面的代码,但它给了我一个null指针异常

Aggregation agg = newAggregation(Customer.class,
            project("customerBirthday").andExpression("month(customerBirthday)").as("customerBirthday_month")
                    .andExpression("day(customerBirthday)").as("customerBirthday_day"),
            group(fields().and("customerBirthday_month").and("customerBirthday_day"))
                    .count().as("count"));
有什么建议吗