Reputation: 2331
Environment
Jersey Eclipselink (JPA)
Entities
Country --- Cities
@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();
}
RESULT
<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>
QUESTION
Why there is no Cities at all even if there is field for it?
How can I get cities as well in same @GET?
Is it even possible, I think so?
Thanks Sami
Upvotes: 1
Views: 197
Reputation: 2331
@XmlTransient---> **THIS OFF!**
public Collection<City> getCityCollection() {
return cityCollection;
}
@XmlTransient off and I moved it to:
@XmlTransient
public Country getCountryCountryId() {
return countryCountryId;
}
And it is working :)
Upvotes: 1