Hibernate ID Generation - Must Read

tl;dr See here for how to properly generate equals and hashCode for Hibernate. The catch is that with Hibernate you end up with a mix of Entity class and HibernateProxy subclasses, which will not match the equals methods suggested in most places. Overview Review the article linked above for the technical details of how equals and hashCode are used by Hibernate. The key is that these need to reflect the primary key of the entity so that when Hibernate needs an object for a database record it can locate it in its session. ...

March 16, 2025 · Nigel Sim

Hibernate Survival Diaries

I’ve been developing with Hibernate since approximately 2005. In that time I’ve spoken with many other experienced developers and compared notes on how they use and don’t use Hibernate. This is a brief summary of some key learnings. Many of the topics discussed here could be considered defects, and in a lot of cases there are tickets, but I haven’t compiled a list here. Some may have actually been fixed (please let me know), but as far as I know this is accurate as of Hibernate 5.4.33. ...

February 28, 2023 · Nigel Sim