@OneToMany property null in Entity after (second) merge
Posted
by iNPUTmice
on Stack Overflow
See other posts from Stack Overflow
or by iNPUTmice
Published on 2010-03-31T11:20:20Z
Indexed on
2010/03/31
11:33 UTC
Read the original article
Hit count: 371
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;
}
© Stack Overflow or respective owner