@OneToMany property null in Entity after (second) merge
- by iNPUTmice
Hi,
I'm using JPA (with Hibernate) and Gilead in a GWT project. On the server side I have this method and I'm calling this method twice with the same "campaign". On the second call it throws a null pointer exception in line 4 "campaign.getTextAds()"
public List<WrapperTextAd> getTextAds(WrapperCampaign campaign) {
campaign = em.merge(campaign);
System.out.println("getting textads for "+campaign.getName());
for(WrapperTextAd textad: campaign.getTextAds()) {
//do nothing
}
return new ArrayList<WrapperTextAd>(campaign.getTextAds());
}
The code in WrapperCampaign Entity looks like this
@OneToMany(mappedBy="campaign")
public Set<WrapperTextAd> getTextAds() {
return this.textads;
}