SlideShare a Scribd company logo
An Introduction to Hibernate
Object-Relational Mapping Technique


Hibernate provides mapping between:
 Java Classes and the database tables.
 The Java data types and SQL data types.
Basic Architecture
Introduction to hibernate
Hibernate Configuration File
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD
     3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
 <session-factory>
   <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
   <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
   <property name="hibernate.connection.url">jdbc:mysql://localhost:3307/libms</property>
   <property name="hibernate.connection.username">root</property>
<!-- JDBC connection pool (use the built-in) -->
      <property name="connection.pool_size">1</property>
<!-- Enable Hibernate's automatic session context management -->
      <property name="current_session_context_class">thread</property>
      <!-- Disable the second-level cache -->
      <property
     name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
      <!-- Echo all executed SQL to stouts -->
      <property name="show_sql">true</property>
      <!-- Drop and re-create the database schema on startup -->
      <property name="hbm2ddl.auto">update</property>
<mapping resource="com/myapp/struts/hbm/Staff.hbm.xml"/>
<mapping resource="com/myapp/struts/hbm/Department.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Hibernate Mapping File
                           <?xml version="1.0"?>
                           <!DOCTYPE hibernate-mapping PUBLIC
                                "-//Hibernate/Hibernate Mapping DTD 3.0//
Field Name     Data Type   EN"
                                "http://www.hibernate.org/dtd/hibernate-
Staff_id       VARCHAR(1   mapping-3.0.dtd">
                           <hibernate-mapping>
               0)           <class name="com.myapp.struts.beans.Staff"
                           table=“Staff" catalog="libms">
Staff_name     VARCHAR(3        <id name="StaffId" type="string">
               0)                   <column name=“Staff_id" length=“10" />
                                    <generator class="assigned" />

Staff_Depart   VARCHAR(3        </id>
                                <property name=“StaffName"
ment           0)          type="string">
                                    <column name=“Staff_name"
                           length="30" not-null="true" />
                                </property>
                                <property name=“StaffDep" type="string">
                                   <column name=“Staff_Department"
                           length=“30" />
                           </class>
public class Employee implements java.io.Serializable {
                                                     private String StaffId;
                                                     private String StaffName;
POJO                                                 private String StaffDep;
                                                    public Staff() {
<?xml version="1.0"?>                               }
                                                    public Staff(String id, String name) {
<!DOCTYPE hibernate-mapping PUBLIC
                                                       this. StaffId = id;
     "-//Hibernate/Hibernate Mapping DTD               this. StaffName = name;
3.0//EN"                                            }
                                                    public Staff(String id, String name, String dep) {
     "http://www.hibernate.org/dtd/hibernate-
                                                      this.id = id;
mapping-3.0.dtd">                                     this.name = name;
<hibernate-mapping>                                   this. StaffDep = dep;
 <class name="com.myapp.struts.beans.Staff"         }

table=“Staff" catalog="libms">
                                                    public String getStaffId() {
     <id name="StaffId" type="string">                return this. StaffId;
         <column name=“Staff_id" length=“10" />     }

         <generator class="assigned" />             public void setStaffId(String id) {
     </id>                                             this. StaffId = id;
                                                    }
     <property name=“StaffName" type="string">
                                                    public String StaffName() {
         <column name=“Staff_name" length="30"         return this. StaffName;
not-null="true" />                                  }
                                                    public void set StaffName(String name) {
     </property>
                                                       this. StaffName = name;
     <property name=“StaffDep" type="string">       }
        <column name=“Staff_Department"           public String get StaffDep() {
                                                       return this. StaffDep;
length=“30" />
                                                    }
</class>                                            public void set StaffDep(String department) {
</hibernate-mapping>                                   this. StaffDep = department;
                                                    }
Basic APIs

   SessionFactory (org.hibernate.SessionFactory)
   Session (org.hibernate.Session)
   Persistent objects and collections
   Transient and detached objects and collections
   Transaction (org.hibernate.Transaction)
   ConnectionProvider
    (org.hibernate.connection.ConnectionProvider)
   TransactionFactory (org.hibernate.TransactionFactory)
SessionFactory (org.hibernate.SessionFactory)




   A SessionFactory is an immutable, thread-safe object, intended
    to be shared by all application threads. It is created once,
    usually on application startup, from a Configuration instance.

   A org.hibernate.SessionFactory is used to obtain
    org.hibernate.Session instances.

   HibernateUtil helper class that takes care of startup and makes
    accessing the org.hibernate.SessionFactory more convenient.
HibernateUtil class
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
  private static final SessionFactory sessionFactory = buildSessionFactory();
  private static SessionFactory buildSessionFactory() {
     try {
        // Create the SessionFactory from hibernate.cfg.xml
        return new Configuration().configure().buildSessionFactory();
     }
     catch (Throwable ex) {
        // Make sure you log the exception, as it might be swallowed
        System.err.println("Initial SessionFactory creation failed." + ex);
        throw new ExceptionInInitializerError(ex);
     }
  }
  public static SessionFactory getSessionFactory() {
     return sessionFactory;
  }
}
Session (org.hibernate.Session)


   A single-threaded, short-lived object representing a
    conversation between the application and the persistent store.
    Wraps a JDBC java.sql.Connection.
   Used for a single request, a conversation or a single unit of
    work.
   A Session will not obtain a JDBC Connection, or a Datasource,
    unless it is needed. It will not consume any resources until
    used.
Persistent, Transient and Detached objects


   Transient - an object is transient if it has just been instantiated using
    the new operator, and it is not associated with a Hibernate Session.
   Persistent - a persistent instance has a representation in the database
    and an identifier value. It might just have been saved or loaded,
    however, it is by definition in the scope of a Session. Hibernate will
    detect any changes made to an object in persistent state and
    synchronize the state with the database when the unit of work
    completes.
   Detached - a detached instance is an object that has been persistent,
    but its Session has been closed. The reference to the object is still
    valid, of course, and the detached instance might even be modified in
    this state. A detached instance can be reattached to a new Session at
    a later point in time, making it (and all the modifications) persistent
    again.
Transaction (org.hibernate.Transaction)


    A single-threaded, short-lived object used by the application to specify
    atomic units of work. It abstracts the application from the underlying
    JDBC, JTA or CORBA transaction.
   Security is provided by this API.
ConnectionProvider
  (org.hibernate.connection.ConnectionProvider)



   A factory for, and pool of, JDBC connections. It abstracts the
    application from underlying javax.sql.DataSource or
    java.sql.DriverManager.
Extended Architecture
JSP              Action Mapping          Struts-config.xml                  Success/Failure
                                                                                                 JSP

    Fetch Values

Action Form
                           Refers
                                                               Action Class
                   Get Parameters


                                             Set Parameters
                                                               Return Values

                                           POJO
                                     Invoke Methods
                                                          Update POJO



                                                        DAO Beans

                                                         Interacts


                                                          JDBC

                                                          Interacts

                                                       DATABASE
This was a short introduction of hibernate.
           Want to know more?
Query me @ mohdzeeshansafi@yahoo.com

      Special Thanks to Mr Asif Iqbal

More Related Content

What's hot (18)

PDF
An introduction into Spring Data
Oliver Gierke
 
KEY
究極のコントローラを目指す
Yasuo Harada
 
PDF
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
lennartkats
 
PDF
Metrics for example Java project
Zarko Acimovic
 
PPTX
Drupal II: The SQL
ddiers
 
PPT
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf Conference
 
PDF
Software architecture2008 ejbql-quickref
jaiverlh
 
PDF
#살아있다 #자프링외길12년차 #코프링2개월생존기
Arawn Park
 
PPTX
Enterprise js pratices
Marjan Nikolovski
 
PDF
Models Best Practices (ZF MVC)
eddiejaoude
 
PDF
Semantic code transformations in MetaJS
Dmytro Dogadailo
 
PDF
Cloudera Sessions - Clinic 3 - Advanced Steps - Fast-track Development for ET...
Cloudera, Inc.
 
PDF
XML-Javascript
tutorialsruby
 
PDF
A Spring Data’s Guide to Persistence
VMware Tanzu
 
PDF
First java-server-faces-tutorial-en
techbed
 
PDF
hibernate
Arjun Shanka
 
PDF
Phactory
chriskite
 
PDF
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
Mohammad Reza Kamalifard
 
An introduction into Spring Data
Oliver Gierke
 
究極のコントローラを目指す
Yasuo Harada
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
lennartkats
 
Metrics for example Java project
Zarko Acimovic
 
Drupal II: The SQL
ddiers
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf Conference
 
Software architecture2008 ejbql-quickref
jaiverlh
 
#살아있다 #자프링외길12년차 #코프링2개월생존기
Arawn Park
 
Enterprise js pratices
Marjan Nikolovski
 
Models Best Practices (ZF MVC)
eddiejaoude
 
Semantic code transformations in MetaJS
Dmytro Dogadailo
 
Cloudera Sessions - Clinic 3 - Advanced Steps - Fast-track Development for ET...
Cloudera, Inc.
 
XML-Javascript
tutorialsruby
 
A Spring Data’s Guide to Persistence
VMware Tanzu
 
First java-server-faces-tutorial-en
techbed
 
hibernate
Arjun Shanka
 
Phactory
chriskite
 
اسلاید جلسه ۹ کلاس پایتون برای هکر های قانونی
Mohammad Reza Kamalifard
 

Viewers also liked (20)

PPT
02 Hibernate Introduction
Ranjan Kumar
 
PPTX
Introduction to Spring Framework
Raveendra R
 
PPT
Hibernate
reddivarihareesh
 
RTF
THE WORLDS NO.1 BLACK MAGIC EXPERT WITH POWERFUL LOVE SPELLS +27631229624
mamaalphah alpha
 
PDF
Hibernate an introduction
joseluismms
 
PPTX
Introduction to Hibernate Framework
Collaboration Technologies
 
PDF
Hibernate An Introduction
Nguyen Cao
 
PDF
Introduction To Hibernate
ashishkulkarni
 
PPT
Hibernate presentation
Manav Prasad
 
DOCX
Molly's Digital Poetry Book
mmhummel
 
PPTX
Seven Factors to Lose Weight the Healthy Way
dabnel
 
PPT
Acute Compartment syndrome
Asi-oqua Bassey
 
PDF
Mld35 engine manual from sdshobby.net
sdshobby
 
PPT
TACPOWER
Neus Sagrera
 
PDF
Programr Brief Overview
_programr
 
PDF
Al Asbab Profile 4
Al Asbab FZ LLC
 
PPTX
การประยุกต์จิตวิทยาเพื่อการเรียนรู้
Mai Amino
 
PPSX
Hazon
prihen
 
PPTX
การประยุกต์จิตวิทยาเพื่อการเรียนรู้
Mai Amino
 
PDF
Issue1
Pauline Ohanna
 
02 Hibernate Introduction
Ranjan Kumar
 
Introduction to Spring Framework
Raveendra R
 
Hibernate
reddivarihareesh
 
THE WORLDS NO.1 BLACK MAGIC EXPERT WITH POWERFUL LOVE SPELLS +27631229624
mamaalphah alpha
 
Hibernate an introduction
joseluismms
 
Introduction to Hibernate Framework
Collaboration Technologies
 
Hibernate An Introduction
Nguyen Cao
 
Introduction To Hibernate
ashishkulkarni
 
Hibernate presentation
Manav Prasad
 
Molly's Digital Poetry Book
mmhummel
 
Seven Factors to Lose Weight the Healthy Way
dabnel
 
Acute Compartment syndrome
Asi-oqua Bassey
 
Mld35 engine manual from sdshobby.net
sdshobby
 
TACPOWER
Neus Sagrera
 
Programr Brief Overview
_programr
 
Al Asbab Profile 4
Al Asbab FZ LLC
 
การประยุกต์จิตวิทยาเพื่อการเรียนรู้
Mai Amino
 
Hazon
prihen
 
การประยุกต์จิตวิทยาเพื่อการเรียนรู้
Mai Amino
 
Ad

Similar to Introduction to hibernate (20)

PPTX
Jsp presentation
Sher Singh Bardhan
 
PDF
Dropwizard
Scott Leberknight
 
PPT
Hibernate
Sunil OS
 
PDF
Struts database access
Abass Ndiaye
 
PPTX
Hibernate
ksain
 
PDF
Integrating SAP the Java EE Way - JBoss One Day talk 2012
hwilming
 
PPTX
Spring framework part 2
Haroon Idrees
 
PDF
Hadoop Integration in Cassandra
Jairam Chandar
 
KEY
MVC on the server and on the client
Sebastiano Armeli
 
PPTX
How to Bring Common UI Patterns to ADF
Luc Bors
 
PDF
How te bring common UI patterns to ADF
Getting value from IoT, Integration and Data Analytics
 
PDF
MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...
jaxconf
 
PDF
JavaScript Fundamentals with Angular and Lodash
Bret Little
 
PDF
Data access 2.0? Please welcome: Spring Data!
Oliver Gierke
 
PPTX
The Past Year in Spring for Apache Geode
VMware Tanzu
 
PPT
Spring data iii
명철 강
 
PPT
jdbc_presentation.ppt
DrMeenakshiS
 
PPT
比XML更好用的Java Annotation
javatwo2011
 
PDF
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Jsp presentation
Sher Singh Bardhan
 
Dropwizard
Scott Leberknight
 
Hibernate
Sunil OS
 
Struts database access
Abass Ndiaye
 
Hibernate
ksain
 
Integrating SAP the Java EE Way - JBoss One Day talk 2012
hwilming
 
Spring framework part 2
Haroon Idrees
 
Hadoop Integration in Cassandra
Jairam Chandar
 
MVC on the server and on the client
Sebastiano Armeli
 
How to Bring Common UI Patterns to ADF
Luc Bors
 
How te bring common UI patterns to ADF
Getting value from IoT, Integration and Data Analytics
 
MVC on the Server and on the Client: How to Integrate Spring MVC and Backbone...
jaxconf
 
JavaScript Fundamentals with Angular and Lodash
Bret Little
 
Data access 2.0? Please welcome: Spring Data!
Oliver Gierke
 
The Past Year in Spring for Apache Geode
VMware Tanzu
 
Spring data iii
명철 강
 
jdbc_presentation.ppt
DrMeenakshiS
 
比XML更好用的Java Annotation
javatwo2011
 
#18.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원IT학원/실업자/재직자환급교육/자바/스프링/...
탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Ad

Recently uploaded (20)

PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
July Patch Tuesday
Ivanti
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Biography of Daniel Podor.pdf
Daniel Podor
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 

Introduction to hibernate

  • 1. An Introduction to Hibernate
  • 2. Object-Relational Mapping Technique Hibernate provides mapping between:  Java Classes and the database tables.  The Java data types and SQL data types.
  • 5. Hibernate Configuration File <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3307/libms</property> <property name="hibernate.connection.username">root</property> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- Enable Hibernate's automatic session context management --> <property name="current_session_context_class">thread</property> <!-- Disable the second-level cache --> <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Echo all executed SQL to stouts --> <property name="show_sql">true</property> <!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">update</property> <mapping resource="com/myapp/struts/hbm/Staff.hbm.xml"/> <mapping resource="com/myapp/struts/hbm/Department.hbm.xml"/> </session-factory> </hibernate-configuration>
  • 6. Hibernate Mapping File <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0// Field Name Data Type EN" "http://www.hibernate.org/dtd/hibernate- Staff_id VARCHAR(1 mapping-3.0.dtd"> <hibernate-mapping> 0) <class name="com.myapp.struts.beans.Staff" table=“Staff" catalog="libms"> Staff_name VARCHAR(3 <id name="StaffId" type="string"> 0) <column name=“Staff_id" length=“10" /> <generator class="assigned" /> Staff_Depart VARCHAR(3 </id> <property name=“StaffName" ment 0) type="string"> <column name=“Staff_name" length="30" not-null="true" /> </property> <property name=“StaffDep" type="string"> <column name=“Staff_Department" length=“30" /> </class>
  • 7. public class Employee implements java.io.Serializable { private String StaffId; private String StaffName; POJO private String StaffDep; public Staff() { <?xml version="1.0"?> } public Staff(String id, String name) { <!DOCTYPE hibernate-mapping PUBLIC this. StaffId = id; "-//Hibernate/Hibernate Mapping DTD this. StaffName = name; 3.0//EN" } public Staff(String id, String name, String dep) { "http://www.hibernate.org/dtd/hibernate- this.id = id; mapping-3.0.dtd"> this.name = name; <hibernate-mapping> this. StaffDep = dep; <class name="com.myapp.struts.beans.Staff" } table=“Staff" catalog="libms"> public String getStaffId() { <id name="StaffId" type="string"> return this. StaffId; <column name=“Staff_id" length=“10" /> } <generator class="assigned" /> public void setStaffId(String id) { </id> this. StaffId = id; } <property name=“StaffName" type="string"> public String StaffName() { <column name=“Staff_name" length="30" return this. StaffName; not-null="true" /> } public void set StaffName(String name) { </property> this. StaffName = name; <property name=“StaffDep" type="string"> } <column name=“Staff_Department" public String get StaffDep() { return this. StaffDep; length=“30" /> } </class> public void set StaffDep(String department) { </hibernate-mapping> this. StaffDep = department; }
  • 8. Basic APIs  SessionFactory (org.hibernate.SessionFactory)  Session (org.hibernate.Session)  Persistent objects and collections  Transient and detached objects and collections  Transaction (org.hibernate.Transaction)  ConnectionProvider (org.hibernate.connection.ConnectionProvider)  TransactionFactory (org.hibernate.TransactionFactory)
  • 9. SessionFactory (org.hibernate.SessionFactory)  A SessionFactory is an immutable, thread-safe object, intended to be shared by all application threads. It is created once, usually on application startup, from a Configuration instance.  A org.hibernate.SessionFactory is used to obtain org.hibernate.Session instances.  HibernateUtil helper class that takes care of startup and makes accessing the org.hibernate.SessionFactory more convenient.
  • 10. HibernateUtil class import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; public class HibernateUtil { private static final SessionFactory sessionFactory = buildSessionFactory(); private static SessionFactory buildSessionFactory() { try { // Create the SessionFactory from hibernate.cfg.xml return new Configuration().configure().buildSessionFactory(); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } public static SessionFactory getSessionFactory() { return sessionFactory; } }
  • 11. Session (org.hibernate.Session)  A single-threaded, short-lived object representing a conversation between the application and the persistent store. Wraps a JDBC java.sql.Connection.  Used for a single request, a conversation or a single unit of work.  A Session will not obtain a JDBC Connection, or a Datasource, unless it is needed. It will not consume any resources until used.
  • 12. Persistent, Transient and Detached objects  Transient - an object is transient if it has just been instantiated using the new operator, and it is not associated with a Hibernate Session.  Persistent - a persistent instance has a representation in the database and an identifier value. It might just have been saved or loaded, however, it is by definition in the scope of a Session. Hibernate will detect any changes made to an object in persistent state and synchronize the state with the database when the unit of work completes.  Detached - a detached instance is an object that has been persistent, but its Session has been closed. The reference to the object is still valid, of course, and the detached instance might even be modified in this state. A detached instance can be reattached to a new Session at a later point in time, making it (and all the modifications) persistent again.
  • 13. Transaction (org.hibernate.Transaction)  A single-threaded, short-lived object used by the application to specify atomic units of work. It abstracts the application from the underlying JDBC, JTA or CORBA transaction.  Security is provided by this API.
  • 14. ConnectionProvider (org.hibernate.connection.ConnectionProvider)  A factory for, and pool of, JDBC connections. It abstracts the application from underlying javax.sql.DataSource or java.sql.DriverManager.
  • 16. JSP Action Mapping Struts-config.xml Success/Failure JSP Fetch Values Action Form Refers Action Class Get Parameters Set Parameters Return Values POJO Invoke Methods Update POJO DAO Beans Interacts JDBC Interacts DATABASE
  • 17. This was a short introduction of hibernate. Want to know more? Query me @ [email protected] Special Thanks to Mr Asif Iqbal