Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Understanding CriteriaQuery

Chris Ramacciotti , first of all, thanks for the great content! :)

Could you please explain what this code exactly does and how can we "fit" it in what we have learned 'til now?

for instance...why are we passing twice the class? third line is quite clear, but 2 firsts ones are...blurred.

Thank you!

``` // UPDATED: Create CriteriaQuery CriteriaQuery<Contact> criteria = builder.createQuery(Contact.class);

// UPDATED: Specify criteria root
criteria.from(Contact.class);

// UPDATED: Execute query
List<Contact> contacts = session.createQuery(criteria).getResultList();