Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Implementing DAO | Fundamentals of Hibernate
course content

Зміст курсу

Java Data Manipulation with Hibernate

Challenge: Implementing DAOChallenge: 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:

  1. Set up the database connection in hibernate.cfg.xml;
  2. Implement the interfaces in the implementation classes;
  3. Implement the necessary methods in the implementation classes;
  4. 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;
  5. Don't forget to use HibernateUtil;
  6. 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:

Link to the Task: GitHub
1. Use the code from the previous chapter as a hint.
2. Don't forget to change the data in hibernate.cfg.xml.
3. Don't forget about the command for SQL Workbench.
4. You can use main to test your solution.

Все було зрозуміло?

Секція 2. Розділ 6
course content

Зміст курсу

Java Data Manipulation with Hibernate

Challenge: Implementing DAOChallenge: 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:

  1. Set up the database connection in hibernate.cfg.xml;
  2. Implement the interfaces in the implementation classes;
  3. Implement the necessary methods in the implementation classes;
  4. 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;
  5. Don't forget to use HibernateUtil;
  6. 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:

Link to the Task: GitHub
1. Use the code from the previous chapter as a hint.
2. Don't forget to change the data in hibernate.cfg.xml.
3. Don't forget about the command for SQL Workbench.
4. You can use main to test your solution.

Все було зрозуміло?

Секція 2. Розділ 6
some-alt