JavaSpringMongoDB填充引用
我试图在Spring MognoDB中创建对另一个模型的引用
我有一个以前使用Mongoose插入MongoDB的文档列表,因此参考如下:
{
...
address: ObjectId("5f596acb8ea1d54128016e97")
}
在Spring MongoDB文档之后,我创建了两个模型:
@Document(collection = "person")
public class Person{
@Id
private String id;
... other attributes
@DBRef
private Address address;
}
第二种模式:
@Document(collection = "address")
public class Address{
@Id
private String id;
... other attributes
}
但是,这无法返回文档,显示以下错误:
No converter found capable of converting from type [org.bson.types.ObjectId] to type [....models.Address]
你知道怎么解决这个问题吗
我还尝试将id
类型更改为ObjectId
,但仍然得到相同的错误
共 (0) 个答案