Fast Track to Hibernate 3 Developers Workshop

Course Description

Hibernate is an open source object/relational (OR) persistence and query service for Java. Hibernate lets you develop persistent classes following common Java idioms - including association, inheritance, polymorphism, composition, and the Java collections framework. The Hibernate Query Language, designed as a minimal object-oriented extension to SQL, provides an elegant bridge between the object and relational worlds. Hibernate also allows you to express queries using native SQL or Java-based Criteria and Example queries. This course covers everything you need to know to begin working with Hibernate in a very short time. It covers all the important concepts necessary to access and update data stored in relational databases. It includes an extensive series of labs to exercise all major capabilities.
3 days
Contact us for pricing
Contact us for dates
Contact us for dates

Prerequisites

Intermediate knowledge of Java programming and a basic understanding of relational databases are recommended.

Hibernate Overview

The Issues with Persistence Layers
Object-Relational Mapping (ORM) Issues
Issues with JDBC Alone
Hibernate Overview
Hibernate Benefits
Hibernate Environments
Hibernate Architecture
More Detailed Architecture

Using Hibernate

Acquiring Hibernate
Using Hibernate
Configuring Hibernate
hibernate.cfg.xml Elements
SessionFactory Configuration
SessionFactory Configuration Properties
The Configuration Class
The SessionFactory Interface
SessionFactory API
The Session Interface
Sessions and Transactions

Mapping a Simple Class

Persistent Entity Classes
Persistent Classes
The Event Class
The id Property
The Hibernate Mapping File
The Element
The Element
The EVENTS Table
Mapping the id Property with
More About Primary Keys
Generating the id Value
Mapping Properties with
Hibernate Mapping Types
Common Hibernate Type Mappings
Filed Access or Property Access
The Mapping File
Hibernate Sessions
The Session Interface
Retrieving Persistent Objects

Logging

Hibernate.show_sql
Apache Log4J
Hibernate log4j.properties File
The log4j.properties File
Modifying log4j.properties for Hibernate
Hibernate Logging Categories

Appendix – Log4J

Apache Log4J
log4j Loggers
Logger Hierarchy
Logger Levels
Appenders
Aprender Additivity
Layout
log4j Configuration File
PatternLayout
Multiple Layouts
Some log4j Appenders

Inserting and Updating

Inserting Instances
Modifying a Persistent Instance
Deleting an Instance

Querying and Hibernate Query Language (HQL)

Hibernate Query Language
HQL Basics
Executing a Query
Other Common Query Methods
Where Clause/Restriction
HQL Operators and Expressions
Query Parameters
Using Query Parameters
Named Queries
Projection Queries
Projection Queries Returning Tuples
Additional Query Capabilities
Aggregate Functions

Transaction Definition

Transaction Lifecycle
Transactions Modularize Systems
Transactions Clarify Systems

Hibernate and Transactions

Hibernate and Transactions
Hibernate Transaction Demarcation
Working with Transactions
The Hibernate Transaction API
Working in a Managed Environment

The Persistence Lifecycle

Hibernate Object States
Transient and Persistent State
Detached and Removed State
Hibernate Object States and Transitions
The Persistence Context
Session/Persistence Context Lifespan
Session-per-Request
Session Propagation
First – Acquiring a SessionFactory Instance
Contextual Session
Using Contextual Sessions
What is the “Current” Context
Contextual Session Scope
The Persistence Context as Cache
Synchronization to the Database
Flushing the Session
Persistence Context and Object Identity
Yes, It’s Complicated

Versioning and Optimistic Locking

Detached Objects and Optimistic Locking
Using a Detached Instance
Optimistic Locking and Versioning
Version Property in Java Class
Version Element in Mapping File
Automatic Version Maintenance
Updating a Detached Instance
session.saveorupdate()
The unsaved-value Attribute
Locking Objects
Lock Modes

Relationships Overview

Object Relationships
Characteristics of Relationships
Directionality
Characteristics of Relationships

Collections of Value Objects

Collections of Values
Modeling a Set of Values
Mapping the Set of Values
Using a Set of Values
More on the Java Collection Type
Using the Java Collection Types
Modeling a List of Values
Mapping a List of Values
Sorted and Ordered Collections
Collections of Components
Mapping Collections of Components

Mapping Entity Relationships

Unidirectional Many-To-One Relationship
The Table Structure – Many-To-One
Mapping the Relationship
Using the Relationship
Bidirectional One-To-Many Relationship
Defining the One-To-Many Relationship
Mapping the One-To-Many Relationship
More on the Inverse Side
Cascading Operations
Transitive Persistence
The Cascade Attribute
Cascade Choices
Choosing Cascade Options
Bidirectional One-To-One Relationship
Mapping a One-To-One Relationship
Many-To-Many Relationship
Defining Many-To-Many Relationship
Mapping Many-To-Many Relationship
Lazy and Eager Loading
Queries Across Relationships
OUTER and FETCH JOIN

Mapping Inheritance

Inheritance
Entity Inheritance
Details of Entity Inheritance
Single-Table Strategy
Class Definitions for Single-Table
Mapping for Single-Table
Single-Table: Pros and Cons
Table per Subclass (Joined Subclass)
Mapping for Table per Subclass
Joined: Pros and Cons
Table per Concrete Class

More on Querying

Projection Queries
Aggregate Queries
Bulk Update and Delete
Executing Bulk Operations
Native SQL Queries
Refining SQL Queries
Retrieving Entities with SQL Queries

Filters

Hibernate Filters
Defining and Attaching Filters
Using a Filter
Mapping a Filter to a Set
Collection Filters

Criteria

Restrictions – Narrowing the Result Set
Restrictions Methods
Navigating Associations
Eager Fetching
Query by Example
Refining the Example
Additional Capabilities

JPA Overview

Java Persistence API Overview
Java Persistence Environments
Hibernate and JPA

Mapping a Simple Class

Entity Classes
Event Entity Mapped with JPA
The Entity Declaration
The Event Class
The id Property
Mapping Properties
Basic Mapping Types

Entity Manager and Persistence Context

The Entity Manager & Persistence Context
Persistence Unit
persistence.xml
Acquiring an EntityManager
Working with Transactions
Retrieving Persistent Objects

Inserts and Queries

Persisting a New Entity
Java Persistence Query Language
Executing a Query
WHERE Clause and Query Parameters
Named Queries
Version Property in Java Class
Versioned Class and Detached Objects

Relationships

JPA Support for Relationships
Mapping the Many-To-One Relationship
Mapping the One-To-Many Relationship
Loading and Cascading
Queries Across Relationships
Inheritance
Entity Definitions for Single-Table
Entity Definitions for Joined

Components and Multi-Table Mapping

Component Overview
Mapping a Component
Multi-Table Mapping

equals() and hashCode()

Defining equals() and hashCode()
Redefining equals()

Caching

Second-Level Cache
Data Appropriate for Caching
Cache Providers
Configuring Caching
Concurrency Strategies
Managing the Caches

Design Considerations

Long Conversations
Session-per-Conversation
Problems with Web Applications
Open Session in View Pattern
Query Efficiency Techniques
Beware of N+1 Select Issue
Prefetching Data in Batches
Data Access Object (DAO)

Hibernate Toolset

Hibernate Tools Overview
Important Note on Versions
Optional – Hibernate Tools
Install Hibernate Tools
Hibernate Console Configuration
Hibernate Console Perspective
Hibernate Configuration View
Class Diagram
HQL Editor
Query Results
Properties View
SQL Preview
Other Capabilities

HibernateHibernate 3JavaJava Persistence APIJPA