Dette kurset gir en omfattende dekning av Hibernate. Kurset legger stor vekt på øvelser, og inneholder massevis av demoer. Du vil være i stand til å bruke Hibernate det øyeblikket kurset er ferdig.
Målgruppe:
This is an intermediate-level Java programming course, designed for developers who wish to understand Hibernate.
Forkunnskaper:
Attending students should be able to use the syntax of the Java language without difficulty.
Lesson: Introduction to Hibernate
- Define Object to Relational (O/R) Mapping (ORM)
- Define the Hibernate Architecture
- Illustrate the benefits of using Hibernate
- Understand the goals of Hibernate
- Understand key functionalities of Hibernate
- Define the different Hibernate types (Entities and values)
- Understand different Persistent representations (POJOs, Maps and XML)
Lesson: Getting started with Hibernate
- Understand the nuts and bolts of Hibernate
- Understand how to map a class to the database
- Understand the configurations involved and their relationships
- List different ways of configuring Hibernate
- Understand the overall syntax of the Hibernate Configuration file
- Understand the overall syntax of a mapping file
- Introduce the org.hibernate.SessionFactory
- Introduce the org.hibernate.Session
- Understand one way of obtain a session using Hibernate contextual sessions
- Supply a basic example of using Hibernate
Session: ORM with Hibernate
Lesson: Basic ORM
- Configure persistent classes
- Configure persistent state of a class
- Understand the requirements for a persistent entity class
- Understand object identity in Hibernate
- Understand how to correctly implement equals and hashCode in Hibernate
- Discuss object identity and a caveat in hashCode and equals implementations
- Discuss different ways of generating unique numbers for keys
- Understand how to influence mapping to columns
- Understand how to map properties of a class to multiple tables
Lesson: Value Type Collections and Components
- Understand how to map composition using Hibernate’s components
- Understand how to use components as composite identifiers
- Understand the different collection types supported
- List different element types: simple types, composite types and entities
- Understand programming restrictions when using collections
- Understand how to map java.util.Set and java.util.List
- Understand how to position elements explicitly in the List
- Understand how to map java.util.SortedSet
- Understand how to correctly use a Comparator
- Understand how to map a java.util.Map
- Understand how to map the key of the map
- Understand Hibernate’s bags
- Introduce Dynamic components
Lesson: Entity Associations (Relations)
- List the different types of associations
- Understand the difference between uni and bidirectional associations
- Understand how to map unidirectional one to one, many to one and one to many associations
- Understand how and when to use join tables
- Understand how to map many-to-many associations
- Understand how to configure bidirectional associations
- Understand how to cascade over associations
Lesson: Mapping Inheritance
- Discuss the three Inheritance ORM strategies
- Discuss the Single Table Inheritance Pattern (i.e. table per class hierarchy)
- Discuss the Class Table Inheritance Pattern (i.e. table per subclass)
- Discuss the Concrete Table Inheritance Pattern (i.e. table per concrete class)
- Discuss Hibernate’s implicit polymorphism strategy
- Understand how to configure these mappings
- Understand the concept of a discriminator
Session: Using Persistent Objects
Lesson: Reading, Updating and Deleting Objects
- Understand the three object states: Transient, Persistent and Detached
- Understand how to transition from the transient to persistent state (i.e. how to make objects persistent)
- Understand how to retrieve hibernated objects using the primary key
- Understand how to retrieve hibernated objects using basic HQL
- Understand how to update entities which are in the persistent state (attached updates)
- Understand how to transition entities from persistent to detached state
- Understand the detached state of an entity
- Discuss the briefcase model
- Understand how to transition from detached (back) to persistent (i.e. how to re-attach detached objects)
- Understand the difference between update and merge
- Removing entities
- Discuss the different cascade options and their impact on entity associations
Lesson: Transactions
- Describe the need for transaction control
- Explain isolation levels
- Discuss the three different ways of demarcating transactions
- Understand the different ways of demarcating transactions in a managed Java EE environment
- Understand how to correctly use the contextual session
- Use the Hibernate Transaction API to hide transaction implementation
- Correctly handle exceptions
- Understand Optimistic -vs- Pessimistic locking schemes
- Implement Optimistic concurrency using Hibernate’s automatic versioning
- Implement Pessimistic concurrency using Lock modes
- List different optimistic lock modes supported in Hibernate
- Understand locking using read for update
- Understand the read for update scope on association (and how to cascade the lock)
Session: Querying in Hibernate
Lesson: Querying for Objects
- Introduce two ways of querying (Criteria and HQL)
- Understand the basic HQL syntax
- Introduce the org.hibernate.Query class
- Work with the results of a query
- Handle different result set element types (unique, array of entity, scalar)
- Use the relationships between entities in your HQL
- Use HQL expressions
- Use aggregate functions
- Use the group by clause
- Understand how to enable Pagination
- Use parametrized HQL
- Understand the concept of Named Queries
- Use the org.hibernate.Criteria to query
- Understand how to use Query By Example (QBE)
Hand-on lab exercises
- Map a class (Member) to the database-The objective is to map a class with fields of different types to the database. This will also enable students to understand how to setup the environment.
- Implement a Composition-The objective of this exercise is to understand how to use Hibernate’s components
- Implement Collections-The objective is to understand how to map different collections.
- Map different associations-The objective is to map different association types to the database in two real-life use cases.
- Map specializations-The objective is to understand how to map class inheritance to the database
- Implement a service-per-request proxy and work with detached objects-The objective is to understand how to implement the service-per-request pattern and how to control the lifecycle of the detached entity.
- Transactions and Concurrency-See the effect of optimistic and pessimistic concurrency and how to develop these schemas