Last active
August 12, 2016 05:52
-
-
Save thjanssen/dc1a1c44fd0facfc90ed7170846b5f20 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Prepare query | |
CriteriaBuilder cb = em.getCriteriaBuilder(); | |
CriteriaQuery<Tuple> q = cb.createTupleQuery(); | |
Root<Author> author = q.from(Author.class); | |
// Select multiple scalar values | |
q.multiselect(author.get(Author_.firstName).alias("firstName"), author.get(Author_.lastName).alias("lastName")); | |
List<Tuple> authorNames = em.createQuery(q).getResultList(); | |
for (Tuple authorName : authorNames) { | |
log.info(authorName.get("firstName") + " " + authorName.get("lastName")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment