Hi guys, in this lesson we will talk about what hibernate is. And we will also talk about basic things of hibernate. hibernate is an object relational mapping tool for visual programming language. This means we have a database like my skin and under database we have some tables. Also, we have a Java project like Spring Boot application. And under this application, we have some Java class.
Hibernate creates the relation between these database tables and these Java classes. To create these relation, we have some annotations on hibernate. First one is entity. With this annotation we can define to class as hibernate object or empty. Second one is table we can specify the database table with using table annotation. In any class, third one is color.
We can specify the column mapping using column annotation. The other one is ID, we can specify ID field in hibernate entity. The other one is generated video databases have some specific default values for example, auto increment or serial increment. To specify this kind of generations, we can use generate it video annotation in hibernate. In hibernate, we can also create connection or relation between entities. These relations can be one to one one to many Many to one or many too many.
How can we describe such kind of relations, for example, in an online elearning website, that our users from different countries and courses, a user can have one country, so the relation is one to one, a user can enroll many courses. So the relation is one too many. A course can be taken by many users. So the relation is also one to many. To keep these user and close relation, we have two options. We can show them with list or we can show them with another table like transaction.
Final thing about hibernate is lesion fetch types. In hibernate. We can optimize relations with fetch strategies. For example, We have a user and country entities and there is a relation between two of them. In our first case, we want to call country information all time when user entity is called. In that case to specify it we can use eager fetch type in hibernate.
Eager fetch type will call country object of user every time then user object is caught. In our second case, we want to call country information when we just need it. In that case, to specify it we can use lazy fetch type in hibernate. Of course, there are other many things in hibernate, but for beginning for our course, this will be enough. That's all. Thank you.