我使用mongo存储库从引用列表中检索值
以下是文档结构:
"order" :{
"orderId": "OR1",
"invoice": [
{
"refNo": "inv12",
"amount": "3000.00"
},
{
"refNo": "inv13",
"amount": "3500.00"
}
]
}
订单类
@Document(collection = "order")
public class Order{
private String orderId;
@DBRef
private List<Invoice> invoice;
}
发票类别
@Document(collection = "invoice")
public class Invoice {
private String refNo;
private BigDecimal amount;
}
我想按发票参考号检索订单,我尝试了下面显示的查询。
@Query("{'invoice': { $elemMatch: {'refNo': ?0 }} }")
List<Order> findOrdersByInvoice(String invoice);
这将产生一个空的结果集。有人能解释一下我哪里做错了吗?
暂无答案!
目前还没有任何答案,快来回答吧!