假设我有2个微服务:Service1和Service2.他们每个人都有自己的数据库.Service1具有EntityA,Service2具有EntityB
EntityA {
Long id;
//other fields
EntityB entity;
}
EntityB{
//other fields
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Spring的RestTemplate来检索和保存数据.问题是:当从Service1的数据库中检索EntityA时,我没有EntityB的数据,因为它们保存在Service2的数据库中,我知道我应该通过RestTemplate进行休息调用以从Service2的数据库中检索EntityB,但是如何关联实体 - EntityA是否仍然包含整个EntityB对象,即使它的字段在除id之外的大部分时间都是空的?我错过了什么?先感谢您.