Зміст курсу
Java Data Manipulation with Hibernate
Java Data Manipulation with Hibernate
Challenge: Implementing DAO
Let's move on to practice. In the previous chapter, we implemented the DAO layer as well as the Service layer for the Employee
entity. In this task, you need to do the same for the Department
entity.
Interfaces such as DepartmentDao
and DepartmentService
have already been created for you. In this task, you should work in implementation classes, such as DepartmentDaoImpl
and DepartmentServiceImpl
.
Your task is to implement all the methods specified in the interfaces.
Here's the workflow for the task:
- Set up the database connection in
hibernate.cfg.xml
; - Implement the interfaces in the implementation classes;
- Implement the necessary methods in the implementation classes;
- You can implement them similarly to how we did it in the previous chapter. It's not difficult. You just need to change the entity names;
- Don't forget to use
HibernateUtil
; - Run the integration tests to check your solution.
Note
To ensure that the integration tests work correctly, you need to execute the following command in the MySQL Workbench query. This command will grant permission to delete data from the table for the tests to run correctly. Don't worry. This database is a test database; later, when we test all the necessary methods and are ready to complete the project, we will create another database that will no longer be a test one.
Command:
Дякуємо за ваш відгук!