【发布时间】:2013-08-29 22:07:05
【问题描述】:
环境
球衣 Eclipselink (JPA)
实体
国家 --- 城市
@OneToMany(cascade = CascadeType.ALL, mappedBy = "countryCountryId")
private Collection<City> cityCollection;
@XmlTransient
public Collection<City> getCityCollection() {
return cityCollection;
}
休息
@GET
@Override
@Produces({"application/xml", "application/json"})
public List<Country> findAll() {
return super.findAll();
}
结果
<countries>
<country>
<country>Finland</country>
<countryId>1</countryId>
<lastUpdate>2013-08-30T00:43:35+03:00</lastUpdate>
</country>
<country>
<country>Sweden</country>
<countryId>2</countryId>
<lastUpdate>2013-08-30T00:43:35+03:00</lastUpdate>
</country>
</countries>
问题
为什么即使有领域也没有城市?
我怎样才能在同一个@GET 中获得城市?
我觉得有可能吗?
谢谢 萨米人
【问题讨论】:
-
关系加载的默认设置是 LAZY。您是否填充了相关实体?
标签: jpa collections entity eclipselink jersey-2.0