I'm thinking of something like a "tips and tricks" section that goes over these 
extensions as well as JDO/JPA things that might be particularly useful with 
GAE, with examples of how they're useful with GAE.  For example, parent-pk, and 
then in Max's recent article, @PrePersist, @PreUpdate, and the JDO 
StoreCallback interface, which I didn't know about.


Ikai L (Google) wrote:
> I'm happy to add this to the official docs if it isn't clear. I think 
> this makes sense under the JPA section or the section about ancestor 
> queries.
> 
> On Sun, Nov 22, 2009 at 11:24 PM, Rusty Wright <[email protected] 
> <mailto:[email protected]>> wrote:
> 
>     There are way too many hidden secrets, like this parent-pk query,
>     that are buried throughout the App Engine documentation.  It would
>     really be nice if these things were more clearly documented.
> 
> 
>     Ikai L (Google) wrote:
>      > Hey Todd,
>      >
>      > There are a few different things you can do here:
>      >
>      > 1. Use the parent-pk filter. It looks something like this:
>      >
>      > query = pm.newQuery("select from Account " +
>      >
>      >                                 "where parent-pk == keyParam " +
>      >                                 "parameters Key keyParam");
>      >
>      >
>      > There's a groups thread about this here:
>      >
>     
> http://groups.google.com/group/google-appengine-java/browse_thread/thread/97ba3209ec6a65de
>      >
>      > and the docs are here:
>      >
>      >
>     
> http://code.google.com/appengine/docs/java/datastore/transactions.html#Using_Transactions(search
>      >
>      > 2. Use the low-level API.
>      >
>      > com.google.appengine.api.datastore.Query has a constructor that
>     takes an
>      > Ancestor key.
>      >
>     
> http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Query.html#Query(com.google.appengine.api.datastore.Key)
>      >
>      > Hope this helps.
>      >
>      > On Mon, Nov 16, 2009 at 4:29 PM, Todd Vierling <[email protected]
>     <mailto:[email protected]>
>      > <mailto:[email protected] <mailto:[email protected]>>> wrote:
>      >
>      >     Test app to reproduce:
>      >
>      >     http://ancestortest.latest.duh-test.appspot.com/
>      >
>      >     Source code:
>      >
>      >    
>     
> http://ancestortest.latest.duh-test.appspot.com/src/ancestortest/AncestorTestServlet.java
>      >    
>     
> http://ancestortest.latest.duh-test.appspot.com/src/ancestortest/UserAccount.java
>      >    
>     
> http://ancestortest.latest.duh-test.appspot.com/src/ancestortest/UserAccountModification.java
>      >
>      >     This sample code basically creates two UserAccount objects and
>      >     attaches a UserAccountModification to one of them.  Then, a query
>      >     (which, unless the datastore is really slow, should return an
>     empty
>      >     list):
>      >
>      >     =====
>      >                Query q = em.createQuery("select m from
>      >     UserAccountModification m where m.modTime < :newest and m.owner
>      >     = :owner order by modTime desc");
>      >                q.setParameter("newest", System.currentTimeMillis() -
>      >     10000L);
>      >                q.setParameter("owner", user1);
>      >                List<UserAccountModification> mods =
>     q.getResultList();
>      >     =====
>      >
>      >     I get the following exception:
>      >
>      >     javax.persistence.PersistenceException: SELECT FROM
>      >     UserAccountModification m WHERE m.modTime < :newest and m.owner
>      >     = :owner ORDER BY modTime desc: Key of parameter value does
>     not have a
>      >     parent.
>      >            at
>      >    
>     org.datanucleus.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException
>      >     (NucleusJPAHelper.java:264)
>      >            at
>     org.datanucleus.jpa.JPAQuery.getResultList(JPAQuery.java:179)
>      >            at
>      >     ancestortest.AncestorTestServlet.doGet(AncestorTestServlet.java:
>      >     46)
>      >
>      >     I must be missing something here.  The docs for GAE talk about
>      >     ensuring the use of ancestor filters when inside a
>     transaction, for
>      >     instance, and there's the ANCESTOR IS operator in GQL.
>      However, I
>      >     can't seem to figure out how properly to express this in JPQL (as
>      >     "ANCESTOR IS" is a syntax error there), and there's no docs
>     that I can
>      >     find on doing this in JPA.
>      >
>      >     The query is meant to find UserAccountModification objects all
>      >     residing under a given "owner", which happens to be the
>     ancestor of
>      >     those objects.  Is there a proper expression for this using JPQL?
>      >
>      >     --
>      >
>      >     You received this message because you are subscribed to the
>     Google
>      >     Groups "Google App Engine for Java" group.
>      >     To post to this group, send email to
>      >     [email protected]
>     <mailto:[email protected]>
>      >     <mailto:[email protected]
>     <mailto:[email protected]>>.
>      >     To unsubscribe from this group, send email to
>      >     [email protected]
>     <mailto:google-appengine-java%[email protected]>
>      >     <mailto:google-appengine-java%[email protected]
>     <mailto:google-appengine-java%[email protected]>>.
>      >     For more options, visit this group at
>      >     http://groups.google.com/group/google-appengine-java?hl=.
>      >
>      >
>      >
>      >
>      >
>      > --
>      > Ikai Lan
>      > Developer Programs Engineer, Google App Engine
>      >
>      > --
>      >
>      > You received this message because you are subscribed to the Google
>      > Groups "Google App Engine for Java" group.
>      > To post to this group, send email to
>     [email protected]
>     <mailto:[email protected]>.
>      > To unsubscribe from this group, send email to
>      > [email protected]
>     <mailto:google-appengine-java%[email protected]>.
>      > For more options, visit this group at
>      > http://groups.google.com/group/google-appengine-java?hl=.
> 
>     --
> 
>     You received this message because you are subscribed to the Google
>     Groups "Google App Engine for Java" group.
>     To post to this group, send email to
>     [email protected]
>     <mailto:[email protected]>.
>     To unsubscribe from this group, send email to
>     [email protected]
>     <mailto:google-appengine-java%[email protected]>.
>     For more options, visit this group at
>     http://groups.google.com/group/google-appengine-java?hl=.
> 
> 
> 
> 
> 
> -- 
> Ikai Lan
> Developer Programs Engineer, Google App Engine
> 
> --
> 
> You received this message because you are subscribed to the Google 
> Groups "Google App Engine for Java" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-appengine-java?hl=.

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=.


Reply via email to