Found the trouble... if you JOIN, you have to alias: JOIN foo.bar bar JOIN bar.baz baz
Also, the trouble with the lazy loading was that I'd closed the EntityManager before trying to get at a lazy-loaded field, so naturally that wasn't gonna work... On Sun, 11 Nov 2007, Nick Johnson wrote: > First, are multiple JOIN clauses supported? (Sanity check) > > I have a set of classes, BinaryResourceReference, BinaryResourceLocale and > BinaryResourceContent. One BinaryResourceReference may have many > BinaryResourceLocales, and each BinaryResourceLocale has one > BinaryResourceContent. > > I find that if I do a JPA query for BinaryResourceReference and JOIN FETCH > its BinaryResourceLocales, then the content field of each > BinaryResourceLocale is null and won't be lazy-loaded. > > If I take another approach and try to join all the way through, with this > query: > > SELECT ref FROM BinaryResourceReference ref JOIN ref.locales locales > JOIN locales.content WHERE ref.scope = ?1 AND ref.path = ?2 AND > ref.extension = ?3 > > then I get this exception: > > Caused by: <openjpa-1.0.0-r420667:568756 nonfatal user error> > org.apache.openjpa.persistence.ArgumentException: Encountered "JOIN > locales . content WHERE" at character 70, but expected: [".", "ABS", > "ALL", "AND", "ANY", "AS", "ASC", "AVG", "BETWEEN", "BOTH", "BY", > "CONCAT", "COUNT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", > "DELETE", "DESC", "DISTINCT", "EMPTY", "ESCAPE", "EXISTS", "FETCH", > "FROM", "GROUP", "HAVING", "IN", "INNER", "IS", "JOIN", > > [snip] > > Presumably this is happening either because multiple joins aren't allowed, > or I'm doing them the wrong way for this case. I suspect it's the latter, > because the parser claims to have been expecting JOIN. > > I've double-checked the field names just to be sure. > BinaryResourceReference#locales is a 1:M to > BinaryResourceReferenceLocales, and BinaryResourceReferenceLocales#content > is a 1:1 to BinaryResourceContent. > > Any thoughts or suggestions? > > Nick > > -- "Courage isn't just a matter of not being frightened, you know. It's being afraid and doing what you have to do anyway." Doctor Who - Planet of the Daleks This message has been brought to you by Nick Johnson 2.3b1 and the number 6. http://healerNick.com/ http://morons.org/ http://spatula.net/