What is Hibernate Architecture?

What is Hibernate Architecture?

Before going start learning What is Hibernate Architecture? we have to know some of the key points as follows.

Persistent

The process of storing the data into permanent place is called persistent.

Persistent logic

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

  1. It does not support query language
  2. It does not provide security
  3. 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.

Example

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.

Example

from studentbean( pojo class name) as sb where sb.id( pojo class variable)=20;

Examples of ORM Tools

  1. Hibernate
  2. EJB-Entity Bean
  3. Ibatics
  4. toplink
  5. JPA

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,

Download: www.hibernate.org

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

  1. It is an open source software. It means we can get the source code of that application
  2. It is light weight component. It means to execute this component no need of application server.
  3. It is object relation mapping (ORM) tool giving the database independent persistent logic. It built on POJO and POJI programming.
  4. Hibernate supports inheritance and polymorphism of OOPS. But EJB does not support inheritance and polymorphism.
  5. Containers or servers are not required.
  6. Hibernate applications are compatible with any java, j2ee technologies.
  7. 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>
  8. Most of the operations in object relational mapping or declarative approach
  9. It gives the support of transactions , connection pooling, caching and middle ware services.
  10. It supports object level relationships i.e one-to-one, one-to-many, many-to-one, many-many
  11. It supports two levels of cache to reduce the network traffic between client and server.
  12. There is no byte code enhancement.
  13. 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.
  14. Hibernate support primary key generation algorithm.
  15. Very easy to learn and apply.

What is Hibernate Architecture

Hibernate integration possible ways

  1. JSP –> Servlet –> EJB Session –> Hibernate –> Database
  2. Struts –> EJB Session –> Hibernate –> Database
  3. Struts –> Spring –> Hibernate –> Database
  4. Spring Web MVC –> Spring J2ee –> Hibernate –> Database

 

 

Leave a Reply