in section 1 we installed MySQL and created the database
Video 7: Hibernate Overview
1- hibernate implements Java Persistence API.
2- in addition hibernate provides some extra annotations
3- in addition hibernate has HQL, a special query language.
in order to use hibernate, you need to have hibernate.properties (or hibernate.cfg.xml) to define your connection. Also you need to provide the mapping between your object and database, this can be done by annotation or xml. After that you just get a session from sessionFactory and start working, basically the sessionFactory hold all the connection and mapping information.
the most important thing in hibernate:
1- no SQL
2- reduce development time
3- sure hibernate abstract you from the database,
Video 8-9: Object Relational Mapping
we should know that we have data model, which is the table in the database and Object model which is a representation for this data as objects, normally you have a class for each table in the database
when you convert from a data model to object model you should be careful of the following differences:
1- Identity: in data model you identify a record by using primary key, in Object Model we use = operator or equals().
2- Association: in data model to associate table we use foreign key, in Object Model we use Object reference
3- Asoociation Navigation: in data model we use join, in Object Model we use get methods on the reference
4- Inheritance: there is no inheritance in data mode, but we have inheritance in Object model
with ORM you achieve:
1- less persistence code, which leads to less development time
2- no need to repeat yourself and build a persistence layer
3- it is less likely to make mistakes, like closing connections
Video 10: Hibernate Demo
it is just a demo, we will not talk about it, just one important thing, we said before that you should use hibernate.properties, however you can also set the configurations via code, nobody does that but you can