Advanced Hibernate™ Training Course

Training » All Courses » Java » Advanced Hibernate™

Course Summary

Advanced Hibernate Training course is designed to push students' OR/M skills to the next level. We skip the basic introduction of what Hibernate is and how to set up the basing mappings, and we move straight to the advanced topics, such as: filters, named queries, complex associations and mappings, advanced HQL, searching by example, Criteria API, transactions, versioning, fetching strategies, performance tuning, and best practices.

[top] Duration

3 days.

[top] Objectives

By taking Marakana Advanced Hibernate Training class, you will:
  • Understand Hibernate search capabilities: named queries, searching by example, Criteria API, advanced HQL, filtering, etc.
  • Be able to model complex entity relationships: one-to-one, many-to-one, one-to-many, many-to-many, bidirectional, etc.
  • Learn how to protect the state of your data through locking (e.g. versioning) and transactions
  • Be able to tune the performance of your Hibernate code through optimized fetching strategies and caching.
  • Learn how to diagnose and troubleshoot problems in your Hibernate code (e.g. the infamous LazyInitializationException)
  • Be able to follow best practices in designing, writing, maintaining, and testing your Hibernate code

[top] Audience

This course is designed for Java architects and developers.

[top] Prerequisites

Students must have solid understanding of the Java language and be familiar with the Hibernate fundamentals, such as simple mappings, basic configuration, basic HQL, and Hibernate's Session API.

Previous exposure to Java EE, and SQL can be helpful.

[top] Instructors

Photo
After graduating with a Computer Science degree from University of Cape Town, South Africa, Martin spent 13 years developing his career with WorldGroup consulting, starting as a Java programmer and ending his career there in 2005 as Chief Technical Officer of a company selling a J2EE infrastructure based product set to Fortune 500's. In 2005 Martin left his position and founded Javadojo, a company dedicated to building cutting edge delivery platform's in Java and hiring the best Java people in the business. Martin has been an educator for the last three years teaching open source technology across the globe.

Additionally Martin has been producing electronic music for the last few years using Ableton Live. He has released two albums and has been playing his music live around the US and at festivals such as the Coachella, Shambhala and Burning Man festivals. More about Martin Folb...
After ten years teaching Computer Science in a University I left in order to apply those skills in a commercial environment. Since then I have gained wide experience in helping many large corporations add value to their IT staff resource by upskilling, cross-training and mentoring developers in the latest software technologies.
My work with some of the world's most successful corporations has given me deep insight into the effective application of appropriate software tools and techniques in today's commercial environment.
My overall strengths include excellent communication and training skills, substantial knowledge and experience of the Java platform and XML technologies, proven judgement in the selection of emerging technologies, and an intelligent, mature approach to any new challenge.
I continue to invest heavily in keeping my knowledge and skills up to date in Java and XML for the enterprise, the relevant programming techniques and libraries, system architectures, and applications. I have retained an enthusiasm for the technical subjects I teach, which has often been commented upon in course evaluations. More about Michael Callaghan...

[top] Outline

Hibernate - Revisited

  • Revisit the role Hibernate plays in our applications
  • Revisit JPA
    • Entity Manager
  • Getting started with a simple Hibernate application
    • Configuration
    • API
    • Mapping a simple class
      • XML vs Annotations
    • Common type mappings
    • Inserting and updating
    • Retrieving persistent objects

Advanced Property and Relationship Mappings

  • Mapping advanced Java data types
  • Mapping inter-entity relationships
    • One to one, one to many, many to one, many to many
    • Parent - child
    • Collections
    • Bidirectional
    • Cascading Operations
    • Transitive persistence
    • Lazy and eager loading
    • Collections of value objects
      • Modeling a set of simple values
      • Mapping collections of components
  • Mapping inheritance
    • Polymorphic support
    • Exploring pros and cons of different strategies
      • Single table
      • Table per subclass
      • Table per concrete class

The Persistance Lifecycle

  • Hibernate Object States
    • Transient, Persistent, Detached, Removed
    • Transitions between states
  • Persistance Context (Session)
    • Lifecycle
    • Acquiring a Session
    • Session per request
    • Session Propagation
    • As Cache
    • Synchronization with the database
    • Flushing
    • Object Identity

Protecting Data

  • Transactions in Hibernate
    • Lifecycle
    • Demarcation
    • API
  • Optimistic vs. Pessimistic locking
  • Versioning
  • Integrating with external transaction managers
    • Managed environment

Finding Your Data

  • Simple "searching" by ID (Session API)
  • Advanced HQL
    • Revisited (syntax and API)
    • Parameters
    • Joins
    • Named queries
    • Functions (e.g. aggregate)
    • Projections (tuples)
  • Searching by example
  • Native queries
  • Criteria API
    • Uses
    • Restrictions
    • Associations
    • Ordering
    • Fetching
  • Filters
    • Defining and attaching filters
    • Using filters
    • Mapping filters to a set
    • Collection filters

Tuning Your Code

  • Fetching strategies: lazy, eager, batch, sub-query loading
  • Caching
    • Second-level Cache
    • Query Caching
    • Data-appropriate caching
    • Cache Providers
    • Cache Configuration
    • Managing caches
  • Query Efficiency
  • N+1 Select Problem
  • Design Considerations
    • Long conversations
    • Session-per-conversation
      • Open Session In View Pattern

Best Practices

  • Entity identity: implementing equals() and hashCode()
  • Designing your DAO layer
  • Troubleshooting problems
  • Testing your DAO code
  • Logging
  • Hibernate Toolset
    • Installing
    • Class Diagram
    • HQL Editor
    • Query Results
    • SQL Preview
  • Q&A

[top] Additional Notes

Depending on the student needs, this class can focus on JPA/Annotation-style (preferred) or XML-based Hibernate mappings.

Hibernate™ is a registered trademark of Red Hat, Inc. Java™ and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. Marakana is not affiliated with these companies.

Marakana.com Runs on Java using Hibernate

Spark Stack

Marakana.com is written in Java using Spring and Hibernate frameworks. We deploy it on Apache Tomcat Application Server. Both Marakana Spark and Apache Tomcat are Java applications and thus run on Java Virtual Machine. Spark uses MySQL database for persistence. Our operating system of choice is Ubuntu Linux, for security and reliability reasons. So we practice what we teach. You will learn from real developers.


[top] Student Testimonials

This was one of the best trainings I have ever done. Doug was beyond knowledgeable and engaged. I greatly enjoyed the discussion and I feel that for the team overall this was a great experience.

Matt - Symantec Corporation