How to update MongoDB document with DbRef using spring mongoTemplate
@Document
class Entity1 {
@Id
String id
@DbRef(lazy=true)
Entity2 entity2;
String test;
}
mongoTemplate.upsert(
new Query(Criteria.where("entity2.$id").is(entity2Id),
new Update().set("test", "newValue"),
Entity1.class);
I got Found $id field without a $ref before it, which is invalid
My question is how to do this with DbRef.
+3
source to share