Adv - Java GTU Study Material Presentations Unit-6 Hibernate 4.0
Adv - Java GTU Study Material Presentations Unit-6 Hibernate 4.0
Advanced Java
Unit-6
Hibernate
Reference Book:
Black Book “ Java server programming” J2EE, 1st ed., Dream Tech Publishers,
2008. 3. Kathy walrath ”
Chapter 15
7
Unit-4 Java Server Pages(JSP) 7 Darshan Institute of Engineering & Technology
Hibernate Framework
Hibernate framework simplifies the development of java
application to interact with the database.
Hibernate is an open source, lightweight, ORM (Object Relational
Mapping) tool.
An ORM tool simplifies the data creation, data manipulation and
data access.
Hibernate is a programming technique that maps the object to the
data stored in the database.
Java
Object ORM Database
Application
Mapping File
Configuration File
Database
Persistent Object
Core object
Hibernate
of Hibernate
Framework
Configuration Session Factory Session
https://www.youtube.com/watch?v=hfv9ZXUzjhk
First-level Cache
Hibernate
The Session object keeps an object under its own control before
committing it to the database.
If you issue multiple updates to an object, Hibernate tries to delay
doing the update as long as possible to reduce the number of
update SQL statements issued.
If you close the session, all the objects being cached are lost.
SQL
ResultSet rs=st.executeQuery("select * from diet");
HQL
Query query= session.createQuery("from diet");
//here persistent class name is diet
SQL
ResultSet rs=st.executeQuery("select * from diet where id=301");
HQL
Query query= session.createQuery("from diet where id=301 ");
//here persistent class name is diet
SQL
String sql = "INSERT INTO Stock VALUES (100, 'abc')";
int result = stmt.executeUpdate(sql);
HQL
Query query = session.createQuery("insert into Stock(stock_code,
stock_name) select stock_code, stock_name from backup_stock");
int result = query.executeUpdate();
11 Develop program to get all students data from database using hibernate. Write
necessary xml files.