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

Course Content

Java Data Manipulation with Hibernate

Challenge: Entity CreationChallenge: Entity Creation

Note

This task will consist of 2 parts.

Setting up the connection:

Your task is to create the necessary database in MySQL using regular SQL queries. I will provide you with the codes for the table that we will use and develop in this course; you just need to insert these codes into your table.

Then, you need to connect your database to the project. I've left a template for you in hibernate.cfg.xml; you just need to insert the link to your database (I recommend using the name testDatabase, as this database will be used to test your solution. When we have a finished project, we will create a new database).

You also need to fill in the username in MySQL (most likely, it will be root) as well as your password.

Don't worry, I won't see your password :).

Here are the commands to create the database and two necessary tables in it.

Use this exact database for this task.

Note

We will continue to use this database further, so please do not delete it after completing the task.

Creating the database and using it:

Creating the employees table:

Creating the departments table:

Creating the entity class:

Next, you need to go to the Department class and make this class an entity class. Use all the necessary annotations learned in previous chapters. You can also use the Project Lombok library, or you can manually write getters, setters, and constructors. The choice is yours.

After you complete the task, run the integration tests I've written, and they will verify the correctness of your task.

Link to the Task: GitHub
  1. 1. Use annotations: @Entity, @Table(name = "departments"), @Id, @GeneratedValue(strategy = GenerationType.IDENTITY), and @Column.
  2. 2. If you encounter any issues with connecting to the database, double-check the database name, username, password, and make sure that these tables exist in the database.

Everything was clear?

Section 2. Chapter 3
course content

Course Content

Java Data Manipulation with Hibernate

Challenge: Entity CreationChallenge: Entity Creation

Note

This task will consist of 2 parts.

Setting up the connection:

Your task is to create the necessary database in MySQL using regular SQL queries. I will provide you with the codes for the table that we will use and develop in this course; you just need to insert these codes into your table.

Then, you need to connect your database to the project. I've left a template for you in hibernate.cfg.xml; you just need to insert the link to your database (I recommend using the name testDatabase, as this database will be used to test your solution. When we have a finished project, we will create a new database).

You also need to fill in the username in MySQL (most likely, it will be root) as well as your password.

Don't worry, I won't see your password :).

Here are the commands to create the database and two necessary tables in it.

Use this exact database for this task.

Note

We will continue to use this database further, so please do not delete it after completing the task.

Creating the database and using it:

Creating the employees table:

Creating the departments table:

Creating the entity class:

Next, you need to go to the Department class and make this class an entity class. Use all the necessary annotations learned in previous chapters. You can also use the Project Lombok library, or you can manually write getters, setters, and constructors. The choice is yours.

After you complete the task, run the integration tests I've written, and they will verify the correctness of your task.

Link to the Task: GitHub
  1. 1. Use annotations: @Entity, @Table(name = "departments"), @Id, @GeneratedValue(strategy = GenerationType.IDENTITY), and @Column.
  2. 2. If you encounter any issues with connecting to the database, double-check the database name, username, password, and make sure that these tables exist in the database.

Everything was clear?

Section 2. Chapter 3
some-alt