Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tbuckel
Created November 7, 2013 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbuckel/7349789 to your computer and use it in GitHub Desktop.
Save tbuckel/7349789 to your computer and use it in GitHub Desktop.
JPA2 - Downcast
Root<Employee> empRoot = cq1.from(getEntityManagerFactory().getMetamodel().entity(Employee.class));
Join<Employee, Project> join = empRoot.join("projects");
Path exp = ((Path)join.as(LargeProject.class)).get("budget");
cq1.where(qb1.equal(exp, new Integer(1000)) );
// --------------
Check for type:
cb.equal(join.type(), cb.literal(LargeProject.class))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment