Hibernate is a library that provides an implementation of ORM ( Object Relation Mapping ) for Java. It was created in 2001 by Gavin King. It allows us to have Java classes that are filled up with the relevant data from the database without us doing a lot of the detail repetitive work.It woks with different databases and takes into consideration the different flavors and differences in the databases. It provides caching capabilities that help with performance.
Other similar libraries are EclipseLink , MyBatis.
We are going to be working with Hibernate Version 5.3.1 . The latest version is 6.
We will not be using an IDE in this tutorial. We will be using batch files for the Windows and script files for the Unix system.
Hibernate can be downloaded from:
https://sourceforge.net/projects/hibernate/
Create a folder such as "C:\hibernate\lib" to store all the jars.
The files are:
antlr-2.7.7.jar
byte-buddy-1.8.12.jar
c3p0-0.9.5.2.jar
classmate-1.3.4.jar
dom4j-1.6.1.jar
geolatte-geom-1.3.0.jar
hibernate-c3p0-5.3.1.Final.jar
hibernate-commons-annotations-5.0.3.Final.jar
hibernate-core-5.3.1.Final.jar
hibernate-envers-5.3.1.Final.jar
hibernate-jpamodelgen-5.3.1.Final.jar
hibernate-osgi-5.3.1.Final.jar
hibernate-proxool-5.3.1.Final.jar
hibernate-spatial-5.3.1.Final.jar
jandex-2.0.3.Final.jar
javassist-3.22.0-GA.jar
javax.interceptor-api-1.2.jar
javax.persistence-api-2.2.jar
jboss-logging-3.3.2.Final.jar
jboss-transaction-api_1.2_spec-1.1.1.Final.jar
jts-core-1.14.0.jar
mchange-commons-java-0.2.11.jar
ojdbc6.jar
org.osgi.compendium-4.3.1.jar
org.osgi.core-4.3.1.jar
postgresql-42.2.2.jar
proxool-0.8.3.jar
slf4j-api-1.6.1.jar
We are going to use Oracle as the database so the "ojdbc6.jar" file had to be downloaded separately. Once we have all the files in the folder we need to include the files in the classpath variable. With Windows we can create 2 files with the contents as below:
Fle: "set1.bat"
set path=c:\jdk_18\bin
set classpath = .;
for %%i in (C:\hibernate\lib\*.jar) do call setclasspath.bat %%i
File: "classpath.bat"
set classpath=%classpath%;%1
Run the file "set1.bat" from the dos command prompt.