SlideShare une entreprise Scribd logo
1  sur  34
JOE JACOB
   Hibernate is a free, open source Java package that
    makes it easy to work with relational databases.

   Hibernate makes it seem as if your database
    contains plain Java objects like you use every day,
    without having to worry about how to get them out
    of (or back into) mysterious database tables.

    Hibernate liberates you to focus on the objects and
    features of your application, without having to
    worry about how to store them or find them later.
   Cost effective.

   Learning is very easy compare to EJB.

   High Performance than EJB

   No more need for JDBC API for Result set handling.

   Switching to other SQL database requires few
    changes in Hibernate configuration file
   Database independent application

   Avoid writing queries

   Avoid JDBC API completely

   Hibernate uses connection pooling technique

   Automatic Key Generation

   Develop the Application in short Period of time
   DB2
   MySQL
   PostgreSQL
   Oracle (any version)
   Microsoft SQL Server
   HypersonicSQL
   Informix
   Ingres
   Interbase
   Pointbase
   Mckoi SQL
   Progress
   FrontBase
   SAP DB
   Sybase
   Hibernate architecture has three main components:
   Connection Management
         Hibernate Connection management service provide efficient
    management of the database connections. Database connection is
    the most expensive part of interacting with the database as it
    requires a lot of resources of open and close the database
    connection.
      
   Transaction management:
         Transaction management service provide the ability to the user
    to execute more than one database statements at a time.
      
   Object relational mapping:
         Object relational mapping is technique of mapping the data
    representation from an object model to a relational data model. This
    part of the hibernate is used to select, insert, update and delete the
    records form the underlying table. When we pass an object to a
    Session.save() method, Hibernate reads the state of the variables
    of that object and executes the necessary query.
   Hibernate is very good tool as far as object
    relational mapping is concern but in terms
    of
    ◦ connection management and
    ◦ transaction management,
    it is lacking in performance and capabilities. So
      usually hibernate is being used with other
      connection management and transaction
      management tools. For example apache DBCP is
      used for connection pooling with the Hibernate.
   Hibernate 3.0 provides three full-featured
    query facilities:
   Hibernate Query Language
   Hibernate Criteria Query API
   Hibernate Native Query
   The Criteria interface allows to create and
    execute object-oriented queries. It is
    powerful alternative to the HQL but has own
    limitations. Criteria Query is used mostly in
    case of multi criteria search screens, where
    HQL is not very effective. 
   Native SQL is handwritten SQL for all
    database operations like create, update,
    delete and select. Hibernate Native Query
    also supports stored procedures. Hibernate
    allows you to run Native SQL Query for all the
    database operations, so you can use your
    existing handwritten sql with Hibernate, this
    also helps you in migrating your SQL/JDBC
    based application to Hibernate.
   Configuring Hibernate

   Persistence Class

   Map the Object to the Database table (Using
    Annotation)

   Setting up the Database
        Insert, Update and Delete records in the table (Hibernate
         automatically creates query to perform this operations)
Make SQL be object oriented
     •Classes and properties instead of tables and columns
     •Polymorphism
     •Associations
     •Much less verbose than SQL
Full support for relational operations
     •Inner/outer/full joins, cartesian products
     •Projection
     •Aggregation (max, avg) and grouping
     •Ordering
     •Subqueries
     •SQL function calls
Simplest HQL Query:

         from AuctionItem

i.e. get all the AuctionItems:

       List allAuctions = session.createQuery(“from AuctionItem”).list();
    •SQL function calls
1. HQL Select Query Example


 Retrieve a stock data where stock code is “7277″.




 Query query = session.createQuery("from Stock where stockCode = :code ");
 query.setParameter("code", "7277");
 List list = query.list();

 Query query = session.createQuery("from Stock where stockCode = '7277' ");
 List list = query.list();
2. HQL Update Query Example


 Update a stock name to “DIALOG1″ where stock code is “7277″

    Query query = session.createQuery("update Stock set stockName =
    :stockName" + " where stockCode = :stockCode");
    query.setParameter("stockName", "DIALOG1");
    query.setParameter("stockCode", "7277");
     int result = query.executeUpdate();

    Query query = session.createQuery("update Stock set stockName =
    'DIALOG1'" + " where stockCode = '7277'");
    int result = query.executeUpdate();
3. HQL Delete Query Example


 Delete a stock where stock code is “7277″.

    Query query = session.createQuery("delete Stock where stockCode =
    :stockCode");
    query.setParameter("stockCode", "7277");
    int result = query.executeUpdate();



  Query query = session.createQuery("delete Stock where stockCode = '7277'");
  int result = query.executeUpdate();
4. HQL Insert Query Example

In HQL, only the INSERT INTO … SELECT … is supported; there is no INSERT INTO … VALUES. HQL
only support insert from another table. For example


Insert a stock record from another backup_stock table. This can also called
bulk-insert statement.


   Query query = session.createQuery("insert into Stock(stock_code,
   stock_name)" + "select stock_code, stock_name from backup_stock");
    int result = query.executeUpdate();


   Note :The query.executeUpdate() will return how many number of record has
   been inserted, updated or deleted.
Like other operations, transactions are performed using the Session object.
Here’s an example:


Session session = sf.openSession();
Transaction tx = session.beginTransaction();

try {
          AuctionItem item =
          (AuctionItem) session.get(ActionItem.class, itemId);
          bid.setItem(item);
          item.getBids().add(bid);
          tx.commit();
} catch (Exception e) {
          tx.rollback();
          throw e;
} finally {
          session.close();
}
Performance of Hibernate web applications is improved using caching by
optimizing the database applications.

The cache actually stores the data already loaded from the database, so that the
traffic between our application and the database will be reduced when the
application want to access that data again. Maximum the application will works
with the data in the cache only. Whenever some another data is needed, the
database will be accessed. Because the time needed to access the database is
more when compared with the time needed to access the cache. So obviously the
access time and traffic will be reduced between the application and the database.
Here the cache stores only the data related to current running application. In order
to do that, the cache must be cleared time to time whenever the applications are
changing.
1.Introduction.
     •First-level cache.
     •Second-level cache.
2.Cache Implementations.
     •EHCache.
     •OSCache.
     •SwarmCache.
     •JBoss TreeCache.
3.Caching Stringategies.
     •Read-only.
     •Read-Write.
     •Nonstriict read-write.
     •Transactional.
4.Configuration.
5.<cache> element.
6.Caching the queries.
First-level cache.

First-level cache always Associates with the Session object. Hibernate uses
this cache by default. Here, it processes one transaction after another one,
means wont process one transaction many times. Mainly it reduces the
number of SQL queries it needs to generate within a given transaction. That is
instead of updating after every modification done in the transaction, it updates
the transaction only at the end of the transaction.
Second-level cache


Second-level cache always associates with the Session Factory object.
While running the transactions, in between it loads the objects at the Session
Factory level, so that those objects will available to the entire application,
don’t bounds to single user. Since the objects are already loaded in the
cache, whenever an object is returned by the query, at that time no need to go
for a database transaction. In this way the second level cache works. Here we
can use query level cache also. Later we will discuss about it.
Cache Implementations


Hibernate supports four open-source cache implementations named
EHCache (Easy Hibernate Cache), OSCache (Open Symphony Cache),
Swarm Cache, and JBoss Tree Cache. Each cache has different
performance, memory use, and configuration possibilities. .
EHCache (Easy Hibernate Cache)
       (org.hibernate.cache.EhCacheProvider)

•   It is fast.
                   • lightweight.
           •      Easy-to-use.
           •      Supports read-only and read/write caching.
           •      Supports memory-based and disk-based caching.
           •      Does not support clustering.
OSCache (Open Symphony Cache)
  (org.hibernate.cache.OSCacheProvider)


•   It is a powerful .
•   flexible package
•   supports read-only and read/write caching.
•   Supports memory- based and disk-based caching.
•   Provides basic support for clustering via either JavaGroups or JMS
SwarmCache (org.hibernate.cache.SwarmCacheProvider)

•   is a cluster-based caching.
•   supports read-only or nonstrict read/write caching .
•   appropriate for applications those have more read operations than write
    operations.
Boss TreeCache (org.hibernate.cache.TreeCacheProvider)

•   is a powerful replicated and transactional cache.
•   useful when we need a true transaction-capable caching architecture .

Contenu connexe

Tendances

Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateThorben Janssen
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code FirstJames Johnson
 
Spring Data - Intro (Odessa Java TechTalks)
Spring Data - Intro (Odessa Java TechTalks)Spring Data - Intro (Odessa Java TechTalks)
Spring Data - Intro (Odessa Java TechTalks)Igor Anishchenko
 
Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3IMC Institute
 
Client Server Communication on iOS
Client Server Communication on iOSClient Server Communication on iOS
Client Server Communication on iOSMake School
 
Hibernate for Beginners
Hibernate for BeginnersHibernate for Beginners
Hibernate for BeginnersRamesh Kumar
 
Change RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBChange RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBApaichon Punopas
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core DataMake School
 
Introduction à DocumentDB
Introduction à DocumentDBIntroduction à DocumentDB
Introduction à DocumentDBMSDEVMTL
 
Big data: current technology scope.
Big data: current technology scope.Big data: current technology scope.
Big data: current technology scope.Roman Nikitchenko
 
Advanced Core Data
Advanced Core DataAdvanced Core Data
Advanced Core DataMake School
 
Azure doc db (slideshare)
Azure doc db (slideshare)Azure doc db (slideshare)
Azure doc db (slideshare)David Green
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questionsArun Vasanth
 

Tendances (20)

Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
Data perisistence in iOS
Data perisistence in iOSData perisistence in iOS
Data perisistence in iOS
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
 
Entity Framework Database and Code First
Entity Framework Database and Code FirstEntity Framework Database and Code First
Entity Framework Database and Code First
 
Spring Data - Intro (Odessa Java TechTalks)
Spring Data - Intro (Odessa Java TechTalks)Spring Data - Intro (Odessa Java TechTalks)
Spring Data - Intro (Odessa Java TechTalks)
 
Hibernate in Nutshell
Hibernate in NutshellHibernate in Nutshell
Hibernate in Nutshell
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3Java Web Programming Using Cloud Platform: Module 3
Java Web Programming Using Cloud Platform: Module 3
 
Client Server Communication on iOS
Client Server Communication on iOSClient Server Communication on iOS
Client Server Communication on iOS
 
Hibernate for Beginners
Hibernate for BeginnersHibernate for Beginners
Hibernate for Beginners
 
Azure DocumentDB
Azure DocumentDBAzure DocumentDB
Azure DocumentDB
 
Change RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDBChange RelationalDB to GraphDB with OrientDB
Change RelationalDB to GraphDB with OrientDB
 
Spring Data in 10 minutes
Spring Data in 10 minutesSpring Data in 10 minutes
Spring Data in 10 minutes
 
Intro to Core Data
Intro to Core DataIntro to Core Data
Intro to Core Data
 
Data Binding
Data BindingData Binding
Data Binding
 
Introduction à DocumentDB
Introduction à DocumentDBIntroduction à DocumentDB
Introduction à DocumentDB
 
Big data: current technology scope.
Big data: current technology scope.Big data: current technology scope.
Big data: current technology scope.
 
Advanced Core Data
Advanced Core DataAdvanced Core Data
Advanced Core Data
 
Azure doc db (slideshare)
Azure doc db (slideshare)Azure doc db (slideshare)
Azure doc db (slideshare)
 
24 collections framework interview questions
24 collections framework interview questions24 collections framework interview questions
24 collections framework interview questions
 

En vedette

Cia de Teatro Nêga Fulô
Cia de Teatro Nêga FulôCia de Teatro Nêga Fulô
Cia de Teatro Nêga FulôSuane Padilha
 
Visuell identitet brs
Visuell identitet brsVisuell identitet brs
Visuell identitet brsMåns Renntun
 
Introduction to android sessions new
Introduction to android   sessions newIntroduction to android   sessions new
Introduction to android sessions newJoe Jacob
 
Brokerage2006 jan callewaert option - the innovation game
Brokerage2006 jan callewaert  option - the innovation gameBrokerage2006 jan callewaert  option - the innovation game
Brokerage2006 jan callewaert option - the innovation gameimec.archive
 
Peter Tyrer Imperial College London 15 October 2015
Peter Tyrer Imperial College London 15 October 2015Peter Tyrer Imperial College London 15 October 2015
Peter Tyrer Imperial College London 15 October 20153GDR
 
Geothermal energy and bathing culture
Geothermal energy and bathing cultureGeothermal energy and bathing culture
Geothermal energy and bathing cultureMimi Popova
 
Music Video Storyboard
Music Video StoryboardMusic Video Storyboard
Music Video Storyboardgeorgina123h
 
Вебинар директора ИДПО Холостовой Е.И. от 20.04.2016
Вебинар директора ИДПО Холостовой Е.И. от 20.04.2016Вебинар директора ИДПО Холостовой Е.И. от 20.04.2016
Вебинар директора ИДПО Холостовой Е.И. от 20.04.2016Viletika
 
colors-(ფერები)
 colors-(ფერები) colors-(ფერები)
colors-(ფერები)Koba GoGua
 
Types of Photography
Types of PhotographyTypes of Photography
Types of PhotographyTom Lord
 
Arvydas sabonis
Arvydas sabonisArvydas sabonis
Arvydas sabonisLituano69
 
Australia Dot Painting Aborigines
Australia    Dot  Painting  AboriginesAustralia    Dot  Painting  Aborigines
Australia Dot Painting AboriginesHeatherP
 
Presentacion
PresentacionPresentacion
Presentacionanamorazn
 

En vedette (18)

Cia de Teatro Nêga Fulô
Cia de Teatro Nêga FulôCia de Teatro Nêga Fulô
Cia de Teatro Nêga Fulô
 
Visuell identitet brs
Visuell identitet brsVisuell identitet brs
Visuell identitet brs
 
Introduction to android sessions new
Introduction to android   sessions newIntroduction to android   sessions new
Introduction to android sessions new
 
Brokerage2006 jan callewaert option - the innovation game
Brokerage2006 jan callewaert  option - the innovation gameBrokerage2006 jan callewaert  option - the innovation game
Brokerage2006 jan callewaert option - the innovation game
 
Peter Tyrer Imperial College London 15 October 2015
Peter Tyrer Imperial College London 15 October 2015Peter Tyrer Imperial College London 15 October 2015
Peter Tyrer Imperial College London 15 October 2015
 
Circuitos 8º a
Circuitos 8º aCircuitos 8º a
Circuitos 8º a
 
Geothermal energy and bathing culture
Geothermal energy and bathing cultureGeothermal energy and bathing culture
Geothermal energy and bathing culture
 
PanMediaNEWS_2009_6_PrimaCool.pdf
PanMediaNEWS_2009_6_PrimaCool.pdfPanMediaNEWS_2009_6_PrimaCool.pdf
PanMediaNEWS_2009_6_PrimaCool.pdf
 
Music Video Storyboard
Music Video StoryboardMusic Video Storyboard
Music Video Storyboard
 
Вебинар директора ИДПО Холостовой Е.И. от 20.04.2016
Вебинар директора ИДПО Холостовой Е.И. от 20.04.2016Вебинар директора ИДПО Холостовой Е.И. от 20.04.2016
Вебинар директора ИДПО Холостовой Е.И. от 20.04.2016
 
May 20 Men US (Pentecost Novena Day 6)
May 20 Men US (Pentecost Novena Day 6) May 20 Men US (Pentecost Novena Day 6)
May 20 Men US (Pentecost Novena Day 6)
 
ZNA partnership
ZNA partnershipZNA partnership
ZNA partnership
 
colors-(ფერები)
 colors-(ფერები) colors-(ფერები)
colors-(ფერები)
 
Types of Photography
Types of PhotographyTypes of Photography
Types of Photography
 
Arvydas sabonis
Arvydas sabonisArvydas sabonis
Arvydas sabonis
 
Les migrants en France et dans les bibliothèques
Les migrants en France et dans les bibliothèquesLes migrants en France et dans les bibliothèques
Les migrants en France et dans les bibliothèques
 
Australia Dot Painting Aborigines
Australia    Dot  Painting  AboriginesAustralia    Dot  Painting  Aborigines
Australia Dot Painting Aborigines
 
Presentacion
PresentacionPresentacion
Presentacion
 

Similaire à Hibernate jj

Advanced Hibernate Notes
Advanced Hibernate NotesAdvanced Hibernate Notes
Advanced Hibernate NotesKaniska Mandal
 
Hibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaHibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaEdureka!
 
Academy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageAcademy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageBinary Studio
 
Hibernate
HibernateHibernate
HibernateAjay K
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentationManav Prasad
 
Java hibernate orm implementation tool
Java hibernate   orm implementation toolJava hibernate   orm implementation tool
Java hibernate orm implementation tooljavaease
 
Hibernate in XPages
Hibernate in XPagesHibernate in XPages
Hibernate in XPagesToby Samples
 
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggetsVirtual Nuggets
 
10 Cache Implementation
10  Cache Implementation10  Cache Implementation
10 Cache ImplementationRanjan Kumar
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile appsIvano Malavolta
 
Hibernate Interview Questions and Answers
Hibernate Interview Questions and AnswersHibernate Interview Questions and Answers
Hibernate Interview Questions and AnswersAnuragMourya8
 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer ReferenceMuthuselvam RS
 

Similaire à Hibernate jj (20)

Advanced Hibernate Notes
Advanced Hibernate NotesAdvanced Hibernate Notes
Advanced Hibernate Notes
 
Hibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaHibernate Interview Questions | Edureka
Hibernate Interview Questions | Edureka
 
Hibernate in Action
Hibernate in ActionHibernate in Action
Hibernate in Action
 
Hibernate
HibernateHibernate
Hibernate
 
Academy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storageAcademy PRO: HTML5 Data storage
Academy PRO: HTML5 Data storage
 
Hibernate
HibernateHibernate
Hibernate
 
What is hibernate?
What is hibernate?What is hibernate?
What is hibernate?
 
What is hibernate?
What is hibernate?What is hibernate?
What is hibernate?
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
Java hibernate orm implementation tool
Java hibernate   orm implementation toolJava hibernate   orm implementation tool
Java hibernate orm implementation tool
 
Hibernate
HibernateHibernate
Hibernate
 
Hibernate in XPages
Hibernate in XPagesHibernate in XPages
Hibernate in XPages
 
Hibernate
HibernateHibernate
Hibernate
 
Free Hibernate Tutorial | VirtualNuggets
Free Hibernate Tutorial  | VirtualNuggetsFree Hibernate Tutorial  | VirtualNuggets
Free Hibernate Tutorial | VirtualNuggets
 
10 Cache Implementation
10  Cache Implementation10  Cache Implementation
10 Cache Implementation
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 
What is hibernate?
What is hibernate?What is hibernate?
What is hibernate?
 
Hibernate Interview Questions and Answers
Hibernate Interview Questions and AnswersHibernate Interview Questions and Answers
Hibernate Interview Questions and Answers
 
Hibernate Developer Reference
Hibernate Developer ReferenceHibernate Developer Reference
Hibernate Developer Reference
 
Introduction to Hibernate
Introduction to HibernateIntroduction to Hibernate
Introduction to Hibernate
 

Dernier

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Dernier (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Hibernate jj

  • 2. Hibernate is a free, open source Java package that makes it easy to work with relational databases.  Hibernate makes it seem as if your database contains plain Java objects like you use every day, without having to worry about how to get them out of (or back into) mysterious database tables.  Hibernate liberates you to focus on the objects and features of your application, without having to worry about how to store them or find them later.
  • 3. Cost effective.  Learning is very easy compare to EJB.  High Performance than EJB  No more need for JDBC API for Result set handling.  Switching to other SQL database requires few changes in Hibernate configuration file
  • 4. Database independent application  Avoid writing queries  Avoid JDBC API completely  Hibernate uses connection pooling technique  Automatic Key Generation  Develop the Application in short Period of time
  • 5. DB2  MySQL  PostgreSQL  Oracle (any version)  Microsoft SQL Server  HypersonicSQL  Informix  Ingres  Interbase  Pointbase  Mckoi SQL  Progress  FrontBase  SAP DB  Sybase
  • 6.
  • 7. Hibernate architecture has three main components:  Connection Management Hibernate Connection management service provide efficient management of the database connections. Database connection is the most expensive part of interacting with the database as it requires a lot of resources of open and close the database connection.     Transaction management: Transaction management service provide the ability to the user to execute more than one database statements at a time.     Object relational mapping: Object relational mapping is technique of mapping the data representation from an object model to a relational data model. This part of the hibernate is used to select, insert, update and delete the records form the underlying table. When we pass an object to a Session.save() method, Hibernate reads the state of the variables of that object and executes the necessary query.
  • 8. Hibernate is very good tool as far as object relational mapping is concern but in terms of ◦ connection management and ◦ transaction management, it is lacking in performance and capabilities. So usually hibernate is being used with other connection management and transaction management tools. For example apache DBCP is used for connection pooling with the Hibernate.
  • 9. Hibernate 3.0 provides three full-featured query facilities:  Hibernate Query Language  Hibernate Criteria Query API  Hibernate Native Query
  • 10. The Criteria interface allows to create and execute object-oriented queries. It is powerful alternative to the HQL but has own limitations. Criteria Query is used mostly in case of multi criteria search screens, where HQL is not very effective. 
  • 11. Native SQL is handwritten SQL for all database operations like create, update, delete and select. Hibernate Native Query also supports stored procedures. Hibernate allows you to run Native SQL Query for all the database operations, so you can use your existing handwritten sql with Hibernate, this also helps you in migrating your SQL/JDBC based application to Hibernate.
  • 12. Configuring Hibernate  Persistence Class  Map the Object to the Database table (Using Annotation)  Setting up the Database  Insert, Update and Delete records in the table (Hibernate automatically creates query to perform this operations)
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. Make SQL be object oriented •Classes and properties instead of tables and columns •Polymorphism •Associations •Much less verbose than SQL Full support for relational operations •Inner/outer/full joins, cartesian products •Projection •Aggregation (max, avg) and grouping •Ordering •Subqueries •SQL function calls
  • 18. Simplest HQL Query: from AuctionItem i.e. get all the AuctionItems: List allAuctions = session.createQuery(“from AuctionItem”).list(); •SQL function calls
  • 19. 1. HQL Select Query Example Retrieve a stock data where stock code is “7277″. Query query = session.createQuery("from Stock where stockCode = :code "); query.setParameter("code", "7277"); List list = query.list(); Query query = session.createQuery("from Stock where stockCode = '7277' "); List list = query.list();
  • 20. 2. HQL Update Query Example Update a stock name to “DIALOG1″ where stock code is “7277″ Query query = session.createQuery("update Stock set stockName = :stockName" + " where stockCode = :stockCode"); query.setParameter("stockName", "DIALOG1"); query.setParameter("stockCode", "7277"); int result = query.executeUpdate(); Query query = session.createQuery("update Stock set stockName = 'DIALOG1'" + " where stockCode = '7277'"); int result = query.executeUpdate();
  • 21. 3. HQL Delete Query Example Delete a stock where stock code is “7277″. Query query = session.createQuery("delete Stock where stockCode = :stockCode"); query.setParameter("stockCode", "7277"); int result = query.executeUpdate(); Query query = session.createQuery("delete Stock where stockCode = '7277'"); int result = query.executeUpdate();
  • 22. 4. HQL Insert Query Example In HQL, only the INSERT INTO … SELECT … is supported; there is no INSERT INTO … VALUES. HQL only support insert from another table. For example Insert a stock record from another backup_stock table. This can also called bulk-insert statement. Query query = session.createQuery("insert into Stock(stock_code, stock_name)" + "select stock_code, stock_name from backup_stock"); int result = query.executeUpdate(); Note :The query.executeUpdate() will return how many number of record has been inserted, updated or deleted.
  • 23.
  • 24. Like other operations, transactions are performed using the Session object. Here’s an example: Session session = sf.openSession(); Transaction tx = session.beginTransaction(); try { AuctionItem item = (AuctionItem) session.get(ActionItem.class, itemId); bid.setItem(item); item.getBids().add(bid); tx.commit(); } catch (Exception e) { tx.rollback(); throw e; } finally { session.close(); }
  • 25.
  • 26. Performance of Hibernate web applications is improved using caching by optimizing the database applications. The cache actually stores the data already loaded from the database, so that the traffic between our application and the database will be reduced when the application want to access that data again. Maximum the application will works with the data in the cache only. Whenever some another data is needed, the database will be accessed. Because the time needed to access the database is more when compared with the time needed to access the cache. So obviously the access time and traffic will be reduced between the application and the database. Here the cache stores only the data related to current running application. In order to do that, the cache must be cleared time to time whenever the applications are changing.
  • 27. 1.Introduction. •First-level cache. •Second-level cache. 2.Cache Implementations. •EHCache. •OSCache. •SwarmCache. •JBoss TreeCache. 3.Caching Stringategies. •Read-only. •Read-Write. •Nonstriict read-write. •Transactional. 4.Configuration. 5.<cache> element. 6.Caching the queries.
  • 28. First-level cache. First-level cache always Associates with the Session object. Hibernate uses this cache by default. Here, it processes one transaction after another one, means wont process one transaction many times. Mainly it reduces the number of SQL queries it needs to generate within a given transaction. That is instead of updating after every modification done in the transaction, it updates the transaction only at the end of the transaction.
  • 29. Second-level cache Second-level cache always associates with the Session Factory object. While running the transactions, in between it loads the objects at the Session Factory level, so that those objects will available to the entire application, don’t bounds to single user. Since the objects are already loaded in the cache, whenever an object is returned by the query, at that time no need to go for a database transaction. In this way the second level cache works. Here we can use query level cache also. Later we will discuss about it.
  • 30. Cache Implementations Hibernate supports four open-source cache implementations named EHCache (Easy Hibernate Cache), OSCache (Open Symphony Cache), Swarm Cache, and JBoss Tree Cache. Each cache has different performance, memory use, and configuration possibilities. .
  • 31. EHCache (Easy Hibernate Cache) (org.hibernate.cache.EhCacheProvider) • It is fast. • lightweight. • Easy-to-use. • Supports read-only and read/write caching. • Supports memory-based and disk-based caching. • Does not support clustering.
  • 32. OSCache (Open Symphony Cache) (org.hibernate.cache.OSCacheProvider) • It is a powerful . • flexible package • supports read-only and read/write caching. • Supports memory- based and disk-based caching. • Provides basic support for clustering via either JavaGroups or JMS
  • 33. SwarmCache (org.hibernate.cache.SwarmCacheProvider) • is a cluster-based caching. • supports read-only or nonstrict read/write caching . • appropriate for applications those have more read operations than write operations.
  • 34. Boss TreeCache (org.hibernate.cache.TreeCacheProvider) • is a powerful replicated and transactional cache. • useful when we need a true transaction-capable caching architecture .

Notes de l'éditeur

  1. To use Hibernate, it is required to create Java classes that represents the table in the database and then map the instance variable in the class with the columns in the database. Then Hibernate can be used to perform operations on the database like select, insert, update and delete the records in the table. Hibernate automatically creates the query to perform these operations.