Last active
January 3, 2016 22:59
-
-
Save elyas-bhy/8532332 to your computer and use it in GitHub Desktop.
A workaround of Google App Engine's limitations regarding Criteria joins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CriteriaBuilder cb = em.getCriteriaBuilder(); | |
CriteriaQuery<Foo> q = cb.createQuery(Foo.class); | |
Root<Foo> foo = q.from(Foo.class); | |
foo.join("bar").alias("b1"); | |
foo.alias("b1"); | |
q.select(foo).where(cb.equal(foo.get("id"), "42")); | |
foo.alias("f1"); | |
TypedQuery<Foo> query = em.createQuery(q); | |
List<Foo> foos = query.getResultList(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The resulting statement is equivalent to:
SELECT f FROM Foo f JOIN f.bar b WHERE b.id = "42"