【发布时间】:2018-04-29 14:25:42
【问题描述】:
我在我的应用程序中使用 mongodb 和 spring boot。在 Area 集合中,城市是 DBRef,但 spring 数据休息方法无法使用城市的 ID 进行搜索。它返回空 JSON,尽管对于那个城市,我的数据库中有区域。我的区域集合和存储库如下。
@Document(collection = "area")
public class Area {
private String name;
private String areaCode;
private String postalCode;
private String latitude;
private String longitude;
private String category;
@DBRef(lazy = false)
private City city;
public interface AreaRepo extends MongoRepository<Area, String> {
@RestResource(path = "byCityId")
List<Area> findByCityId(@Param(value = "cityId") String cityId);
其他集合中的相同关系是工作文件。
【问题讨论】:
标签: java mongodb spring-boot spring-data-rest