Introduction to Hibernate


Audience
Developers and other advanced Java professionals that will be designing, developing and creating enterprise-wide applications using Hibernate.
   

Duration

4 Days
   
Course Abstract
This course utilizes a combination of instructor-led discussions and interactive workshops to demonstrate the advantages of using Hibernate for enterprise application development. This course will focus on: Hibernate architecture, various classes, use of Configuration and Session Factories, persistence management and object states, mapping associations, use of HQL, performance issues, patterns and best practices and the transaction processing aspects.
   
Objectives

After completing this course, students will be understand the following:

  • Understand the capabilities of using Hibernate
  • Define the Hibernate architecture
  • Understand the role of Configuration and Session Factory
  • Depict the persistence management aspects of Hibernate
  • Illustrate different mapping associations
  • Discussion of subclassing and inheritance
  • Illustrate the use of Hibernate Query Language (HQL) in enterprise applications
  • Discuss fetching strategies and performance impacts
  • Demonstrate the importance of caching
  • Understand the role of JDBC and JTA transactions
  • Illustrate the handling of transaction failures
  • Demonstrate different associated tools: POJO, Ant and Eclipse plugins
   
Class Format Lecture and Lab
   
Prerequisites

Each student should have a basic understanding of the internet and have been exposed to the Java programming language.

Course Topics

The following list represents the sections and topics discussed in this virtual instructor-led course offering.

Introduction

• Classroom logistics
• Course overview
• Tools and software discussion

Hibernate Overview

• Object Relational mismatch
• What is an ORM?
• Alternatives to Hibernate (EJB, IBatis, JDBC)
• Hibernate architecture overview
• Introduction to Hibernate classes

Configuration and Session Factory

• Discussion of Configuration object
• Discussion of Session Factory object
• Configuration properties
• JDBC properties
• Other properties
• Building a Configuration
• Programmatically
• Using .properties file
• Using XML configuration file
• Combining build methods
• Reusing the Session Factory
• Threadlocal variable pattern

Session

• Persistence management
• HelloWorld example
• Simple Employee mapping
• CRUD examples
• insert
• get vs. load
• update
• delete
• Review of Javadoc for Session
• Object States
• Review of State Transition diagram
• Transient state
• Persistent state
• Detached state
• Maintaining object identity
• Re-attaching detached objects

Mapping Associations

• Entity types
• Value types
• Components
• Hibernate Types
• Custom value types

Advanced Mappings

• Subclasses and inheritance
• Other mappings

Query and Criteria

• Hibernate Query Language (HQL)
• WHERE clause
• Sorting
• Projections
• Criteria queries

Fetching Strategies and Performance

• Review of Hibernate fetching
• Strategies for JOIN, SUBSELECT, BATCH
• Lazy initialization
• Transitive persistence
• Cascade feature
• Impact of fetching strategies

Caching (Using EhCache)

• Cache concepts
• First Level Cache
• Second Level Cache
•Cache Modes
•Using statistics to monitor cache
•EhCache Configuration

Patterns and Best Practices

• Threadlocal pattern
• Save Session in View
• DAO Pattern