Hibernate in java
Hibernate is Important for Object Relational and Query service for Java. With the help of Hibernate we can map Java classes to database tables, Hibernate allows us to directly deals with the database without creating tables in Sql editor because we directly map the java classes to database tables Via XML Mapping files and Configuration files (which we will discuss later) and while mapping java classes to the database tables Hibernate allows us to use following…
- Sql Server
- Sybase SQL Server
JDBC (Java Data-Base Connectivity)
As you all know About JDBC while making connection to database in Java language which abbreviated as (Java Data-base Connectivity) is an (API) Application Programming Interface for Java, consist of all necessary Java packages, important libraries and Operating Systems files predefined in it. With the help of JDBC we can learn how to Access a database and it is also Known as default Java API and uses JDBC drivers (in Java programming languages), before that ODBC API abbreviated as (Open Data-Base Connectivity) uses ODBC drivers (which was written in C Language).
Why Hibernate Replace JDBC……?
The two main reasons for left JDBC is written below:-
- Because in many online and Banking Application when we transfer data from one application to another application occurs in the form of objects, but when we store data in a database by using JDBC that object will be converted into plain text, because JDBC don’t allows us to transfer object’s directly in object form.
- Because in JDBC we have to write Sql queries in many places, but executed the queries, if we change the table structure and modified it, our JDBC code will not work and we will have to modify and redeploy our project again and again which is major headache.
Positive Points of Hibernate
- Platform Independent : Hibernate is (ORM) abbreviated as Object Relational Mapping designed for Java and considered as Open Source Framework created by Gavin King in early 2001 under the License of LGPL.
- Improved Performance with Caching: Hibernate is fast as compared to JDBC because caching is used in this framework, it acts as Interface b/w Java application and Database to Minimize the number of database Operations due to this applications achieve better performance.
- Independent SQL queries: As similar to Sql, HQL (Hibernate Query Language) is also an object-oriented version of SQL. HQL creates the independent queries. So we Don’t need to write Sql queries, but before Hibernate, If we need to change the Database for our Application, we need to change the all SQL queries as well the table Context which is very Difficult task.
- Auto generated tables with XML mapping files : It is Possible only with Hibernate to create the tables of the database automatically just by inserting the some mapping files to the Hibernate Applications. So we will not need to create database tables in Sql Editor.
- Retrieval of values from database is now easy: We can also fetch the records of multiple tables with the help of Hibernate.
Negative Points of Hibernate
- Boiler Plate Problem: Who can think , Hibernate also has some disadvantages that is boilerplate problem, in this case we need to write similar codes in same application or file, but later spring eliminated this.
- Performance and time: If we have small project with some extent of database tables then there is no need to use hibernate framework and if we still using hibernate then it will be totally wastage of time.
- Performance Issues: As we know Hibernate is little bit slower because of run time operations Hibernate creates database tables at run time therefore we have to face issues with reflection.
for more updates about java c++ and other technology stay connected with softwoodcoder .