Skip to content

📚 Learning and exploring Hibernate ORM (the Java-based Object Relational Mapping framework)

Notifications You must be signed in to change notification settings

dgroomes/hibernate-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hibernate-playground

📚 Learning and exploring Hibernate ORM (the Java-based Object Relational Mapping framework).

Hibernate ORM

Your relational data. Objectively.

-- https://hibernate.org/orm

Description

I want to lean Hibernate better. It can be complex because ORM itself is tricky and because Hibernate has developed a rich feature set over many years (along with a rich set of idiosyncrasies). I will use the JPA (jakarta) annotations when it is idiomatic but I will generally prefer to learn Hibernate directly instead of by sticking strictly to the JPA APIs.

NOTE: This project was developed on macOS. It is for my own personal use.

Standalone subprojects

This repository illustrates different concepts, patterns and examples via standalone subprojects. Each subproject is completely independent of the others and do not depend on the root project. This standalone subproject constraint forces the subprojects to be complete and maximizes the reader's chances of successfully running, understanding, and re-using the code.

The subprojects include:

basic/

A basic demo of Hibernate ORM.

See the README in basic/.

hql/

An illustration of Hibernate's Hibernate Query Language (HQL).

See the README in hql/.

criteria/

An illustration of the Criteria API within the Jakarta Persistence API.

See the README in criteria/.

caching/

Illustrating Hibernate's caching behavior by focussing on trace-level logs.

See the README in caching/.

sqlite/

Connect Hibernate to a SQLite database.

See the README in sqlite/.

codegen/

Use the Hibernate Tools library to codegen Java source code (entities) from an existing database schema.

See the README in codegen/.

Wish List

General clean-ups, TODOs and things I wish to implement for this project:

  • DONE Implement basic/
  • DONE Implement a joins/ project
  • DONE Consider using Hibernate Tools, try out the codegen. I like the jOOQ codegen, for example.
  • DONE Create a SQLite-specific project to showcase the interesting things with a Hibernate-to-SQLite integration: specifically the community dialects.
  • DONE Consider splitting joins/ into subprojects hql/ and criteria/. This way, we can contrast the differences more easily. Specifically, I want to contrast the "N + 1 selection problem". With the Criteria API, we have the option to get a nice "full fetch". But with HQL, we are stuck with subsequent fetches.
  • DONE Create a caching/ project. I want to learn second-level caching. This is an advanced topic and I know it is full of pitfalls. I want to explore it in a controlled environment and understand how I can leverage second-level caching for read-heavy systems that can tolerate minutes/hours/days duration of stale data.

Reference

  • GitHub repo: jooq-playground
    • This is another project of my own. Compare jooq-playground with hibernate-playground as a way to compare jOOQ and Hibernate.

About

📚 Learning and exploring Hibernate ORM (the Java-based Object Relational Mapping framework)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages