Let us attempt an instance of using Hibernate to provide Java perseverance in a separate application. We will go through different steps occupied in creating Java Application using Hibernate technology.
The primary step in creating an application is to construct the Java POJO class or classes, depending on the application that will be persisted to the database. Let us think our Employee class with getXXX and setXXX methods to make it JavaBeans obedient class.
A POJO (Plain Old Java Object) is a Java entity that doesn't expand or apply some specific classes and interfaces respectively necessary by the EJB framework. All normal Java substance is POJO.
When you create a class to be persisted by Hibernate, it's main to provide JavaBeans yielding code as well as one attribute which would work as index like id attribute in the Employee class.
Second action would be creating tables in your database. There would be one table matching to each object you are willing to provide resolution. Consider above substance need to be stored and retrieved into the following RDBMS table:
This movement is to form a mapping file that instructs Hibernate how to map the define class or classes to the database tables.
You should save the mapping article in a file with the arrange <class name>.hbm.xml. We saved our mapping article in the file Employee.hbm.xml. Let us observe little detail about the mapping document:
There are other attributes and elements accessible which will be used in a mapping certificate and I would try to cover as many as feasible while discussing other Hibernate related topics.
At last, we will create our application class with the main () method to run the application. We will use this application to save few Employees’ records and then we will apply CRUD operations on those records.
Here are the steps to accumulate and run the above mention application. Make sure you have set PATH and CLASSPATH correctly before arranged for the compilation and execution.
You would get following result, and records would be created in EMPLOYEE table.
If you check your EMPLOYEE table, it should have following records:
Hibernate Related Interview Questions
|J2EE Interview Questions||Core Java Interview Questions|
|JSP Interview Questions||Java-Springs Interview Questions|
|Java Struts Interview Questions||Log4j Interview Questions|
|Software Development Lifecycle (SDLC) Interview Questions||NHibernate Interview Questions|
|Spring MVC Framework Interview Questions||Apache Struts 2 Interview Questions|
|Spring Aop Interview Questions|
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.