[Draft] Training Guide ‐ Hibernate - vinhtbkit/bkit-kb GitHub Wiki

Hibernate is an Object/Relational Mapping solution for Java environments. The term Object/Relational Mapping refers to the technique of mapping data from an object model representation to a relational data model representation (and vice versa).

image

Target: Knowledge about the Hibernate and how to use it effectively.
Expected Duration: 80 hours.

Qualification criteria:

  • What is Hibernate?
  • Mapping type in Hibernate?
  • List the associations.
  • Distinguish Hibernate and JPA.

Architecture [REQUIRED]

  • Have an overview of the structure of Hibernate in in Spring.

Domain model [REQUIRED]

  • Mapping types
  • Basic values
  • Embeddable values
  • Entity types
  • Naming strategies
  • Identifiers
  • Associations
  • ...

Bootstrap [REQUIRED]

  • How to config to bootstrap Hibernate:
  • Native bootstrapping
  • JPA bootstrapping

Schema Generation [REQUIRED]

  • Know how to Hibernate generate the database from the entity mappings.

Persistence Context [REQUIRED]

  • What is Persistence Context?
  • The role of the Persistence Context.

Flushing [REQUIRED]

  • Why do we need flushing?

Database Access [REQUIRED]

  • How to connect Hibernate with the specific database?

Transactions [REQUIRED]

  • What is a transaction?
  • What is JTA?
  • How to use?
  • Transaction patterns?

Locking [REQUIRED]

  • Optimistic Locking
  • Pessimistic Locking
  • How to apply with Hibernate?

Fetching [REQUIRED]

  • When should the data be fetched? Now? Later?
  • How should the data be fetched?
  • Fetching types: static, dynamic

Batching [REQUIRED]

  • How to deal with OutOfMenmory when using batching?

Caching [OPTIONAL]

  • What is first level caching?
  • What is second level caching?
  • How to apply second level caching?
  • Query caching, entity caching

Interceptors and Events [OPTIONAL]

  • Hibernate provide the interface to help us intercept action of the Session
  • Jakarta Persistence Callbacks

Java API for HQL and JPQL [REQUIRED]

  • Distinguish HQL and JPQL
  • How to use them?

Criteria [REQUIRED]

  • Besides the HQL and JPQL we have the Criteria to help the query become more type-safe
  • How to use the criteria?

Spatial [OPTIONAL]

  • Hibernate provides the Spatial help we can handle the geographic data.

Hibernate Vector module [OPTIONAL]

  • A vector database is a necessary database if we work with AI/ML.

References:

Quizzes

  1. Can you distinguish Hibernate and JPA?

  2. What are the differences between hibernate Session and JPA EntityManager?

  3. What's happened with this code:

Session session = sessionFactory.openSession();
session.beginTransaction();
session.save( new Event( "Hello, this is an event!", new Date() ) );
session.flush();
session.getTransaction().rollback();
session.close();