我有以下方法春数据蒙戈不绑定某些参数
@Query(value = "{storeId: ?0, code: ?1, $or: [ { campaignId: ?2}, {campaignId: ''}, {campaignId: null}], $or: [ {$and: [ {'effectiveDate.from': { $lte: ?3}}, {'effectiveDate.to': { $gte: ?3}} ]}, {$and: [ {'effectiveDate.from': { $lte: ?4}}, {'effectiveDate.to': { $gte: ?4}} ]}]}")
List<GiftCard> findByGiftCardExisting(
String storeId, String code, String campaignId, LocalDateTime from, LocalDateTime to);
查询已使用蒙戈的控制台测试弹簧蒙戈库。 但是,运行应用程序时,我得到一个JSONParseException。经过一番挖掘,我已经注意到参数$ 2没有像预期那样受到约束。
{storeId: "L_STORE", code: "TESTE1", $or: [ { campaignId: ?2}, {campaignId: ''}, {campaignId: null}], $or: [ {$and: [ {'effectiveDate.from': { $lte: { "$date" : "2017-04-03T03:00:00.000Z"}}}, {'effectiveDate.to': { $gte: { "$date" : "2017-04-03T03:00:00.000Z"}}} ]}, {$and: [ {'effectiveDate.from': { $lte: { "$date" : "2017-04-03T03:00:00.000Z"}}}, {'effectiveDate.to': { $gte: { "$date" : "2017-04-03T03:00:00.000Z"}}} ]}]}
其余参数按预期工作。有人可以请指出什么是错的?
发生什么情况,如果您简化@Query只使用一个CAMPAIGNID而不是3?我想知道春季的数据是否会让人困惑。 – Gary