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 - 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.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Querying with the Jakarta Persistence Query Language (JPQL)3m 4s
-
(Locked)
Demo: Querying with JPQL3m 1s
-
(Locked)
Using native queries1m 37s
-
(Locked)
Demo: Querying with native queries2m 8s
-
(Locked)
Leveraging the Criteria API2m 41s
-
(Locked)
Demo: Leveraging the Criteria API3m 54s
-
(Locked)
Challenge: Query an entity using JPQL56s
-
(Locked)
Solution: Query an entity using JPQL2m 12s
-
(Locked)
-