You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Sebastian <no...@gmx.net> on 2008/01/25 00:48:14 UTC

Re: @OneToMany -> null collection?

hi Marc,

I am facing the same issue right now with OpenJPA 1.0.1. Did you ever 
find a solution for this?

Thanks,
Seb

Marc Siegel wrote:
> Hi Patrick,
> 
> The following code:
> Collection<GaCampaign> gaCampaigns = gaAccount.getGaCampaigns();
> 
> Is returning null, not even an empty Collection, even though the data
> in the database is set up correctly. In the database, there are 63
> rows in GaCampaign with a gaAccountId of 10, which should match the
> implied foreign key query from the code above.
> 
> Here is a simplified view of the two annotated classes:
> 
> public class GaAccount {
>     @OneToMany(mappedBy="gaAccount", fetch=FetchType.LAZY)
>     protected Collection<GaCampaign> gaCampaigns;
> 
>     public Collection<GaCampaign> getGaCampaigns() {
> 	return gaCampaigns;
>     }
> 
>     public void setGaCampaigns(Collection<GaCampaign> gaCampaigns) {
> 	this.gaCampaigns = gaCampaigns;
>     }
> }
> 
> public class GaCampaign {
>     @ManyToOne
>     @JoinColumn(name="gaAccountId")
>     protected GaAccount gaAccount;
> 
>     public GaAccount getGaAccount() {
> 	return gaAccount;
>     }
> 
>     public void setGaAccount(GaAccount gaAccount) {
> 	this.gaAccount = gaAccount;
>     }
> }
> 
> Can you shed any light on this problem? I don't think
> gaAccount.getGaCampaign() should be returning (null) in any case,
> right?
> 
> Thanks again,
> -Marc
>