From the course: Java Persistence with JPA and Hibernate
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Solution: Art Class Management app, part 5 - JPA Tutorial
From the course: Java Persistence with JPA and Hibernate
Solution: Art Class Management app, part 5
(upbeat music) - Here's how you can write the queries to retrieve the data that Orange Valley Community Arts Association needs. The first JPQL query is for listing all the students. I've written the query as "SELECT s FROM Student s". S is the reference variable for the student entity. Then call the create query method of the entity manager and pass the query. The query returns student entity instances, so the type should be student. After that, retrieve the result list and print using a four H loop. The second query is to list the students who are attending classes on Monday. Since the day of the week is in the art class entity, I query from the art class entity. So the query goes like this. SELECT c.students FROM ArtClass c WHERE c.dayOfWeek equals to Monday. C is the reference variable for the art class entity. The art class entity has a list of students. I'm retrieving it with c.students. Then the where clause contains the filter criteria. The day of the week has to be Monday. The…
Contents
-
-
-
-
-
-
-
-
-
(Locked)
JPQL queries10m 47s
-
(Locked)
Joins with JPQL9m 11s
-
(Locked)
Named queries5m 15s
-
(Locked)
Aggregate functions8m 43s
-
(Locked)
ORDER BY, GROUP BY, and HAVING9m 17s
-
(Locked)
Native queries5m 11s
-
(Locked)
Criteria queries12m 8s
-
(Locked)
Challenge: Art Class Management app, part 51m 4s
-
(Locked)
Solution: Art Class Management app, part 55m 19s
-
(Locked)
-
-