What is Hibernate Architecture?
Table of Contents
- 1 What is Hibernate Architecture?
Before going start learning What is Hibernate Architecture? we have to know some of the key points as follows.
The process of storing the data into permanent place is called persistent.
The logic that is used to connect with the database is called persistent logic.
Ex: JDBC code, Hibernate code, I/O STreams
We can store the data into files by using I/O streams
Ex: abc.txt, xyz.txt
Java App ——> I/O Stream/Serialization———> files
But storing the data into the files is not recommended because
- It does not support query language
- It does not provide security
- Maintaining large amount of data is very complex.
So if you want to store the data into permanent then we go for the database.
Object Relation Mapping (ORM)
It is the process of mapping between java class with table name, member variables with table columns names and object data with table row data having synchronization between objects with table row data is called object relational mapping tool.
synchronization means modification on java object will be immediately reflect on the table vice-versa.
What is difference between JDBC based persistence logic and ORM based persistent logic?
In the JDBC, we are writing the queries based on the database table name and column name so it is database dependent logic.
SELECT * FROM STUDENT(table name) WHERE ID(column name)=20;
In the ORM based persistent logic we can frame the queries based on the POJO class name and POJO class member variables. So this logic is database independent persistent logic.
from studentbean( pojo class name) as sb where sb.id( pojo class variable)=20;
Examples of ORM Tools
- EJB-Entity Bean
What is hibernate? It is an open source, light weight object relational mapping (ORM) tool to develop the database independent persistence logic in Java, J2ee based application.
Author: Cavin King,
Installation of Hibernate
Installation of hibernate is nothing but download hibernate software in the form of zip, extract the zip and collect hibernate related jar files and place under the class path. When java application uses other than J2sdk API that means third party API’s. That API related main jar files and dependent jar files must be added in the class path.
Here we are going to describing hibernate which is most useful and easily integrate with java and j2ee technologies.
Features of hibernate
- It is an open source software. It means we can get the source code of that application
- It is light weight component. It means to execute this component no need of application server.
- It is object relation mapping (ORM) tool giving the database independent persistent logic. It built on POJO and POJI programming.
- Hibernate supports inheritance and polymorphism of OOPS. But EJB does not support inheritance and polymorphism.
- Containers or servers are not required.
- Hibernate applications are compatible with any java, j2ee technologies.
- Hibernate gives the support of database independent query language i.e. HQL. Hibernate software converts HQL queries into SQL queries by using <property name=”hbmddl>true</property>
- Most of the operations in object relational mapping or declarative approach
- It gives the support of transactions , connection pooling, caching and middle ware services.
- It supports object level relationships i.e one-to-one, one-to-many, many-to-one, many-many
- It supports two levels of cache to reduce the network traffic between client and server.
- There is no byte code enhancement.
- Hibernate applications are scalable applications. Scalability means if the application gives the same response irrespective of the number of clients request that applications are scalable application.
- Hibernate support primary key generation algorithm.
- Very easy to learn and apply.
Hibernate integration possible ways
- JSP –> Servlet –> EJB Session –> Hibernate –> Database
- Struts –> EJB Session –> Hibernate –> Database
- Struts –> Spring –> Hibernate –> Database
- Spring Web MVC –> Spring J2ee –> Hibernate –> Database
Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development.
I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.