1
新泽西 的EclipseLink(JPA)
实体
国家---城市
@OneToMany(cascade = CascadeType.ALL, mappedBy = "countryCountryId")
private Collection<City> cityCollection;
@XmlTransient
public Collection<City> getCityCollection() {
return cityCollection;
}
REST
@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中获得城市?
这是否可能,我认为呢?
感谢 萨米
默认设置是懒惰。你有没有填充你的相关实体? – gerrytan