Challenge: Query
It's time to practice
In the previous chapter, we implemented 2 methods in the Employee
service layer. We used queries to fetch the necessary data, and now you will have to do a similar task.
Your work will involve 4 classes:
DepartmentDaoImpl
;EmployeeDaoImpl
;DepartmentServiceImpl
;EmployeeServiceImpl
.
You need to implement methods such as getAll
and getEmployeesWithSalaryMoreThan(Double salary)
. To implement these methods, you will need to use either Query
or NativeQuery
, depending on what you choose to use, HQL or SQL. You will also need to use parameter substitution and return a list.
After you implement the methods, you can test your solution in the Main
class, and then run the tests that I have written for you to check if you have implemented everything correctly.
Note
Don't forget to set up a connection to your database in
hibernate.cfg.xml
.
Kiitos palautteestasi!
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Kysy minulta kysymyksiä tästä aiheesta
Tiivistä tämä luku
Näytä käytännön esimerkkejä
Awesome!
Completion rate improved to 4.35
Challenge: Query
Pyyhkäise näyttääksesi valikon
It's time to practice
In the previous chapter, we implemented 2 methods in the Employee
service layer. We used queries to fetch the necessary data, and now you will have to do a similar task.
Your work will involve 4 classes:
DepartmentDaoImpl
;EmployeeDaoImpl
;DepartmentServiceImpl
;EmployeeServiceImpl
.
You need to implement methods such as getAll
and getEmployeesWithSalaryMoreThan(Double salary)
. To implement these methods, you will need to use either Query
or NativeQuery
, depending on what you choose to use, HQL or SQL. You will also need to use parameter substitution and return a list.
After you implement the methods, you can test your solution in the Main
class, and then run the tests that I have written for you to check if you have implemented everything correctly.
Note
Don't forget to set up a connection to your database in
hibernate.cfg.xml
.
Kiitos palautteestasi!