Here's some additional information:
- OpenJPA 1.0
- SQLiteJDBC
I replaced the implicit LAZY loading with an explicit FETCH JOIN:
Query query = em.createQuery("SELECT a from GaAccount a LEFT
JOIN FETCH a.gaCampaigns WHERE :clientEmail = a.clientEmail");
Now I am getting an error caused by having the wrong JoinColumn. It
appears that OpenJPA is ignoring my @JoinColumn annotation!
org.apache.openjpa.lib.jdbc.ReportingSQLException: no such column:
t1.gaAccount_id {SELECT t0.id, t0.createdAt, t0.updatedAt,
t0.isChanged, t0.synchronizedAt, t0.clientEmail, t0.customerId,
t0.descriptiveName, t1.gaAccount_id, t1.id, t1.createdAt,
t1.updatedAt, t1.isChanged, t1.synchronizedAt, t1.dailyBudget,
t1.endDay, t1.googleId, t1.name, t1.startDay, t1.status FROM GaAccount
t0 LEFT OUTER JOIN GaCampaign t1 ON t0.id = t1.gaAccount_id WHERE (? =
t0.clientEmail) ORDER BY t1.gaAccount_id ASC} [code=0, state=null]
Where the error states "t1.gaAccount_id", it is ignoring
GaCampaign.java which states:
public class GaCampaign extends EntityWithSynchronizedAt {
...
@ManyToOne
@JoinColumn(name="gaAccountId")
protected GaAccount gaAccount;
...
}
Has anyone seen this before? Is there something I can fix in my SQLite
DBDictionary subclass?
-Marc
On 11/1/07, Marc Siegel <[EMAIL PROTECTED]> 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
>