Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Query | Fundamentals of Hibernate
Java Data Manipulation with Hibernate

Challenge: QueryChallenge: 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:

  1. DepartmentDaoImpl;
  2. EmployeeDaoImpl;
  3. DepartmentServiceImpl;
  4. 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.

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 setting parameters in the query. This is done using the setParameter() method.
4. To obtain a list from the query, use the getResultList() method.
5. You can use main to test your solution.

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

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

Зміст курсу

Java Data Manipulation with Hibernate

Challenge: QueryChallenge: 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:

  1. DepartmentDaoImpl;
  2. EmployeeDaoImpl;
  3. DepartmentServiceImpl;
  4. 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.

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 setting parameters in the query. This is done using the setParameter() method.
4. To obtain a list from the query, use the getResultList() method.
5. You can use main to test your solution.

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

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