Hibernate is an ORM (object relational mapping) tool which is better than JDBC.
Hibernate framework is opensource under the LGPL license and lightweight because it uses POJO classes for data transfer between application and database.
Hibernate is Easy to maintain and it will increases productivity.
Hibernate has versioning and time stamp feature with this we can know how many number of times data is modified.
Hibernate has its own query language, i.e hibernate query language which is database independent so that it supports various databases.
Hibernate supports collections(List,Set,Map).
Hibernate supports inheritance, i.e if we save the derived class object, then its base class object will also be stored into the database which indicates inheritance.
Hibernate supports polymorphism
Hibernate supports associations by managing the data stored across multiple tables by applying relations.
Hibernate has an exception translator , which converts checked exceptions of JDBC in to unchecked exceptions of hibernate. So all exceptions in hibernate are unchecked exceptions , so no need to handle exceptions explicitly by writing try, catch blocks or no need to use throws keyword next to method.
Hibernate supports relationships like One-To-Many,One-To-One, Many-To-Many-to-Many, Many-To-One.
- Hibernate supports Lazy loading , annotations along with XML.
Hibernate supports caching mechanism so that the number of interactions between an application and the database will be reduced, by using this caching technique an application performance will be increased automatically.
Hibernate has capability to generate primary keys automatically while we are storing the records into database.
Hibernate provided Dialect classes, so we no need to write sql queries in hibernate, instead we use the methods provided by that API.
Pagination in hibernate is quite simple.
Advantages of Hibernate
Hibernate Architecture
Hibernate application has four layers.
- Java application layer.
- Hibernate framework layer
- Backhand api layer
- Database layer
About JDBC , JTA , JNDI
Hibernate uses various existing Java APIs, like JDBC, Java Transaction API(JTA), and Java Naming and Directory Interface (JNDI).
JDBC provides a basic level of abstraction of functionality common to relational databases, allowing almost any database with a JDBC driver to be supported by Hibernate.
JNDI and JTA allow Hibernate to be integrated with J2EE application servers.
Hibernate Objects:The Hibernate architecture includes many objects as shown in above detailed view.
- Configuration
- SessionFactory
- Session
- TransactionFactory
- Query
- Criteria
- Configuration Object:
It is the first Hibernate object you create in any Hibernate application and usually created only once during application initialization.
It represents a configuration or properties file required by the Hibernate. The Configuration object provides two key components:
- Database Connection: This is handled through one or more configuration files supported by Hibernate. These files are hibernate.properties and hibernate.cfg.xml.
- Class Mapping Setup : This component creates the connection between the Java classes and database tables.
-
SessionFactory:
Configuration object is used to create a SessionFactory object which inturn configures Hibernate for the application using the supplied configuration file and allows for a Session object to be instantiated. The SessionFactory is a thread safe object and used by all the threads of an application.
The SessionFactory is heavyweight object so usually it is created during application start up and kept for later use. You would need one SessionFactory object per database using a separate configuration file. So if you are using multiple databases then you would have to create multiple SessionFactory objects.
The SessionFactory is a factory of session and client of ConnectionProvider. It holds second level cache (optional) of data. The org.hibernate.SessionFactory interface provides factory method to get the object of Session.
-
Session:
The session object provides an interface between the application and data stored in the database.
It holds a first-level cache (mandatory) of data. The org.hibernate.Session interface provides methods to insert, update and delete the object. It also provides factory methods for Transaction, Query and Criteria.
It is lightweight and designed to be instantiated each time an interaction is needed with the database. Persistent objects are saved and retrieved through a Session object.This object should not be kept open for a long time because they are not usually thread safe.
-
Transaction:
The transaction object specifies the atomic unit of work that deals with with the database and most of the RDBMS supports transaction functionality. The org.hibernate.Transaction interface provides methods for transaction management.
Transactions in Hibernate are handled by an underlying transaction manager and transaction (from JDBC or JTA).
This is an optional object and Hibernate applications may choose not to use this interface, instead managing transactions in their own application code.
-
TransactionFactory:
It is a factory of Transaction objects. It is optional.
-
Query Object:
Query objects use SQL or Hibernate Query Language (HQL) string to retrieve data from the database and create objects. A Query instance is used to bind query parameters, limit the number of results returned by the query, and finally to execute the query.
-
Criteria Object:
Criteria object are used to create and execute object oriented criteria queries to retrieve objects.
-
ConnectionProvider:
It is a factory of JDBC connections. It abstracts the application from DriverManager or DataSource. It is optional.
Hibernate Introduction
What is Hibernate ?
1) Hibernate framework is an Object-relational mapping (ORM) tool which interacts with the database tables.
2) It is open source , light weight , ORM (Object Relational Mapping) tool given by Gavin King.
3) It is called as ORM tool because it maps application domain model objects (POJO class objects) to the relational database tables with the help of a mapping file(xml).
4) It is purely for persistance and simplifies CRUD(Creating , Reading , Updating , Deleting) operations. It internally uses JDBC API to interact with database.
5) It is suitable for all types of applications (Desktop , mobile , stand alone apps) and can run with or with our server.
ORACLE ATG INSTALLATION AND CONFIGURATION
Here in this page we will discuss how to set up Oracle ATG in our local system and configure it.
Steps to be Followed :
1. First set JAVA_HOME and PATH Environment variables.
Where JAVA_HOME points to your JDK directory and PATH point to your
JDK / bin directory.
Note : Install JDK in any of your root directory like C drive not in program files
and your directories should be like below.
JAVA_HOME="C:\Java\jdk1.8.0_xx".
PATH+="C:\Java\jdk1.8.0_xx\bin".
For PATH variable add the JDK/bin directory by using ";" (semicolon);
Where xx denotes your java version update number.
Set the above Environment variables in your system.
For in detail how to install JAVA and environment variables in your system .
Please go to : How to Install Java and Environment variables.
2. Install Weblogic in your system and start the Weblogic server.
On Linux, enter: ./startWebLogic.sh
On Windows, start : startWebLogic.cmd file
WEBLOGIC INSTALLATION
1. First download the weblogic from the link Download Oracle Weblogic by
accepting the terms and conditions.
2. Create a folder Oracle in C drive or D drive eg : [C:\Oracle] and after that
create an environment variable ORACLE_HOME as variable name and
value will be C:\Oracle in my case.
3. After that check whether environment variable set to the directory or not.
By using following command in command prompt.
=> echo %ORACLE_HOME%
Then it should print the as below. If not recheck and restart your system.
4. Then extract the downloaded weblogic zip folder and copy the
fmw_12.2.1.2.0_wls_quick jar in your C:\Oracle folder.
5. Open command prompt and go to C:\Oracle by typing below command.
=> cd C:\Oracle
6. If java is not installed properly you will not able to proceed further steps.
If you didn't installed Java earlier go to : Java Installation Steps and
install Java first.
JAVA INSTALLATION ON WINDOWS
JAVA INSTALLATION :
Note: Before installing Java in your machine , Uninstall all older or other versions of Java and check whether your required Java version is already Installed bcoz sometimes our required version might be already installed .
Steps to Install Java (JDK) in your machine :
1. First of all check whether java already installed or not installed.
To check which version of java installed in your machine.
Go to command prompt and type the following command :
// For Displaying the JRE version
cmd> java -version
java version "1.8.0_xx"
Java(TM) SE Runtime Environment (build 1.8.0_xx-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
//For Displaying the JDK version
cmd> javac -version
javac 1.8.0_xx
Here as per above screenshot installed version is 1.8.0_25 .
If java is not properly installed on your system then you will get a message as below screenshot.'java' is not reconnized as an internal or external command.
So , after checking java version then go for uninstalling the installed java and install required version of your java version.
Uninstall java from controlpanel => uninstall or change a program => uninstall your old java.
2. Go to http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html .
As per your system configuration whether it is 32 bit or 64 bit download the related JDK.
⇒ "Java SE 8u{xx}", where {xx} is the latest update number ⇒ Click the "JDK Download" button after accepting the "Accept License agreement" radio button.
JDK in : C:\Program Files\Java\jdk1.8.0_25
JRE in : C:\Program Files\Java\jre1.8.0_31
3. After installation of JDK and JRE , we have to set or edit the PATH environment variable in
our system.
WHAT IS THE NEED OF PATH VARIABLE ?
Windows OS searches the current directory and the directories listed in the PATH environment
variable for executable programs.
JDK's programs (such as Java compiler javac.exe and Java runtime java.exe) reside in directory"C:\Program Files\Java\jdk1.8.0_xx\bin" .
So we have to set PATH variable in our system which points to the directory "C:\Program Files\Java\jdk1.8.0_xx\bin".
In general we call JDK installed directory as "JAVA_HOME".
JAVA_HOME="C:\Program Files\Java\jdk1.8.0_xx".
PATH="C:\Program Files\Java\jdk1.8.0_xx\bin".
How to Set or Edit PATH Variable in our system ?
To edit the PATH environment variable in Windows XP/Vista/7/8/10:
- Launch "Control Panel" ⇒ "System" ⇒ Click "Advanced system settings".
- Switch to "Advanced" tab ⇒ "Environment Variables".
- Under "System Variables", scroll down to select "Path" ⇒ "Edit...".
- 1. In "Variable value" field, insert "c:\Program Files\Java\jdk1.8.0_xx\bin" (Replace xx with your installation upgrade number)
- 2. IN FRONT of all the existing directories, followed by a semi-colon (;) which separates the JDK's binary directory from the rest of the existing directories.
- Note: DO NOT DELETE any existing entries; otherwise, some existing applications may not run.
- 1. You see a table listing the existing PATH entries.
- Click "New" ⇒ Enter the JDK's binary directory "c:\Program Files\Java\jdk1.8.0_xx\bin" (Replace xx with your installation's upgrade number!!!)
- ⇒ Select "Move Up" to move it all the way to the top.
2. In "Variable value" field, INSERT "c:\Program Files\Java\jdk1.8.0_xx\bin" (Replace xx with your installation upgrade number!!!)
- 3. IN FRONT of all the existing directories, followed by a semi-colon (;) which separates the JDK's binary directory from the rest of the existing directories.
- Note: Observe in the path variable they are many other application locations . This is the reason while editing PATH variable should be careful with out deleting existing applications.
=> Sometimes even if you installed Properly it may not reflect in cmd .
In such scenarios restart your system.
=> For checking Environment variabes set properly or not . Use the
following commands and it should show it's corresponding path you set.
=>echo %JAVA_HOME% which should show JDK directory.
=>echo %ORACLE_HOME% which should show appserver home directory.
=>echo %PATH% which show JDK/bin directory along with other applications
installed.
150 ATG MCQ'S
1. ATG MCQ'S 1-10
2. ATG MCQ'S 11-20
3. ATG MCQ'S 21-30
4. ATG MCQ'S 31-40
5. ATG MCQ'S 41-50
6. ATG MCQ'S 51-60
7. ATG MCQ'S 61-70
8. ATG MCQ'S 71-80
9. ATG MCQ'S 81-90
10. ATG MCQ'S 91-100
11. ATG MCQ'S 101-110
12. ATG MCQ'S 111-120
13. ATG MCQ'S 121-130
14. ATG MCQ'S 131-140
15. ATG MCQ'S 141-150
ATG INTERVIEW QUESTIONS : ATG INTERVIEW Q&A's
Featured Post
H1B Visa Stamping at US Consulate
H1B Visa Stamping at US Consulate If you are outside of the US, you need to apply for US Visa at a US Consulate or a US Embassy and get H1...
-
Ques 1 : Which declaration of the main method below would allow a class to be started as a standalone program. (A) public static int main(c...
-
1. Two Sum Two Sum Solution 2. LRU Cache LRU Cache Solution 3. Number Of Islands 4. Longest Palindromic Substring 5. Lowest...
-
basics Linux fundamentals like system calls , strace , linux mange memory, shared memory, kernel using, boot process, DNS resolving ( how t...