From the course: Java Persistence with JPA

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Demo: Querying with JPQL

Demo: Querying with JPQL - Java Tutorial

From the course: Java Persistence with JPA

Demo: Querying with JPQL

- [Instruction] Now that you understand how JPQL is used, let's see it in action. I've navigated to the employee repository implementation, and let's look for the getEmployeesByExperience method. Just keep scrolling, there we go. On line 59, our getEmployeesByExperience. You'll see that the JPQL syntax here, on line 61 and 62, is very similar to the syntax of SQL. The syntax of the select query consists of two mandatory parts: first the SELECT clause, and next the FROM clause. The SELECT defines the format of the query result. The FROM clause defines the entity or entities from which the result will be obtained. Then, we have the optional WHERE clause. You can also use the ORDER BY, like I'm doing here, and other clauses like GROUP BY, to order the results set by a particular field. In this case, we are retrieving records where years of experience is greater than the past in value stored in the years of experience.…

Contents