How are you deploying your app (JDK version, are you using an appserver, etc.)?

Are you running the OpenJPA enhancer?

-Patrick

On Nov 1, 2007 12:20 PM, Marc Siegel <[EMAIL PROTECTED]> wrote:
> Sure, the object model consists of two classes.
> GaAccount has OneToMany with GaCampaign, which reciprocally has
> ManyToOne with it.
>
> Here's how I am testing the problem:
>
> em.getTransaction().begin();
>         //Query query = em.createQuery("SELECT a from GaAccount a
> WHERE :clientEmail = a.clientEmail");
>         Query query = em.createQuery("SELECT a from GaAccount a LEFT
> JOIN FETCH a.gaCampaigns WHERE :clientEmail = a.clientEmail");
>         query.setParameter("clientEmail", "[EMAIL PROTECTED]");
>         GaAccount gaAccount = (GaAccount) query.getSingleResult();
>         Collection<GaCampaign> gaCampaigns = gaAccount.getGaCampaigns();
>         int numCampaigns = gaCampaigns.size();
> em.getTransaction().commit();
>
> As you can see
>   1.  I can't get the LAZY fetch to work as advertised - I must use
> LEFT JOIN FETCH to retrieve the collection. Why?
>   2.  SQL=TRACE reveals that all objects created from the query were
> then updated with an UPDATE statement at the commit() line. Why?
>
> For example:
> 4629  com.leadgenllc.lib  TRACE  [main] openjpa.jdbc.SQL - <t 8310256,
> conn 164819> executing prepstmnt 5717555 UPDATE GaCampaign SET
> createdAt = ?, updatedAt = ?, isChanged = ?, synchronizedAt = ?,
> dailyBudget = ?, endDay = ?, googleId = ?, name = ?, startDay = ?,
> status = ?, gaAccountId = ? WHERE id = ? [params=(Timestamp)
> 2007-11-01 14:20:29.85, (Timestamp) 2007-11-01 15:18:51.286, (int) 0,
> (Timestamp) 2007-11-01 14:20:31.107, (long) 250000, (Date) 2007-10-11,
> (int) 23096971, (String) Campaign (B) [001], (Date) 2007-10-08,
> (String) Deleted, (long) 10, (long) 175]
>
> Thanks in advance,
> -Marc
>
>
>
> On 11/1/07, Patrick Linskey <[EMAIL PROTECTED]> wrote:
> > That should not be happening; can you describe your object model in
> > more detail? How are you deploying your app?
> >
> > -Patrick
> >
> > On Nov 1, 2007 11:21 AM, Marc Siegel <[EMAIL PROTECTED]> wrote:
> > > Hi Folks,
> > >
> > > When I was using JBoss, I used @PreUpdate methods to record the time
> > > of last modification for many entities.
> > >
> > > Using OpenJPA with SQL=TRACE, it appears that all entities that are
> > > queried during a transaction are committed at the end of that
> > > transaction, even if not modified. This is a problem for me because
> > > the @PreUpdate is being called and updating the modification time,
> > > when in truth no modifications were made, only queries.
> > >
> > > Can anyone shed any light on this problem?
> > >
> > > Thanks in advance,
> > > -Marc
> > >
> >
> >
> >
> > --
> > Patrick Linskey
> > 202 669 5907
> >
>



-- 
Patrick Linskey
202 669 5907

Reply via email to