Hi Daryl, On Apr 6, 2009, at 8:03 AM, Daryl Stultz wrote:
Hey all, I'm new to JPA. I'm trying to learn to write queries. Suppose I haveGrandParents, Parents and Children entities with the obvious relationship. How do I write a query that fetches all three levels? I want something likethis: select gp from GrandParent as gp from GrandParent join fetch gp.parents join fetch gp.parents.childrenThe first fetch works (if I comment out the second) but the second doesn't. I've tried a number of variations but can't seem to get the second level tofetch. (Posted the above to general JPA forum.) I am told JPA 1.0 supports only one level fetch. Is there some OpenJPAextension for fetching more? I don't really need this right now, I'm justtrying to understand it all.
Fetch groups are intended to support this use case. Not JPA standard, and also not guaranteed to fetch all instances in one database round trip. But it might work for you.
Craig
Thanks. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:[email protected]
Craig L Russell Architect, Sun Java Enterprise System http://db.apache.org/jdo 408 276-5638 mailto:[email protected] P.S. A good JDO? O, Gasp!
smime.p7s
Description: S/MIME cryptographic signature
