> For the complete documentation index, see [llms.txt](https://kgoralski.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kgoralski.gitbook.io/wiki/hibernate.md).

# Hibernate

**JPA beyond copy paste by Jakub Kubrynski** [https://youtu.be/EZwpOLCfuq4](https://www.youtube.com/watch?v=EZwpOLCfuq4\&t=2408s) - this is video might be a little bit outdated but still contains a lot of useful **tips**, the content of this video is described here:&#x20;

* <https://www.youtube.com/watch?v=EZwpOLCfuq4&lc=Ugxp9JpfgF9Hv5nfGyl4AaABAg>&#x20;
* <https://speakerdeck.com/jkubrynski/jpa-beyond-copy-paste>

**Vlad Mihalcea** is Java Champion and author of probably the **best book** about Hibernate. His blog and tutorials are great.&#x20;

* <https://vladmihalcea.com/books/high-performance-java-persistence/>
* <https://vladmihalcea.com/tutorials/hibernate/>
* <https://www.youtube.com/channel/UCYeDPubBiFCZXIOgGYoyADw/playlists>

**N+1 problem**

* <https://www.javacodemonk.com/what-is-n-1-problem-in-hibernate-how-will-you-identify-and-solve-it-894097b9>&#x20;
* <https://vladmihalcea.com/how-to-detect-the-n-plus-one-query-problem-during-testing/>&#x20;
* <https://dziadeusz.github.io/prevent-n+1-from-creeping-in/>

**List vs Bag vs Set**

* <https://vladmihalcea.com/hibernate-facts-favoring-sets-vs-bags/>

**equals & hashcode and UUID usage**

* <https://thoughts-on-java.org/ultimate-guide-to-implementing-equals-and-hashcode-with-hibernate/>
* &#x20;<https://stackoverflow.com/questions/5031614/the-jpa-hashcode-equals-dilemma>
* &#x20;<https://vladmihalcea.com/hibernate-and-uuid-identifiers/>

**Performance tips**

* &#x20;<https://vladmihalcea.com/14-high-performance-java-persistence-tips/>
* <https://www.slideshare.net/VladMihalcea/jpa-and-hibernate-performance-tips>
* <https://www.youtube.com/watch?v=BTdTEe9QL5k>

**Optimistic locking**

* <https://vladmihalcea.com/optimistic-locking-version-property-jpa-hibernate/>&#x20;
* <https://vladmihalcea.com/a-beginners-guide-to-database-locking-and-the-lost-update-phenomena/>

**Common pitfalls**

* &#x20;<https://codete.com/blog/jpa-8-common-pitfalls/>
* &#x20;<https://codete.com/blog/5-common-spring-transactional-pitfalls/>

**JPA 2.2 Streaming (fancy stuff)**

* <https://vladmihalcea.com/whats-new-in-jpa-2-2-stream-the-result-of-a-query-execution/>

![](/files/-MRxogu7Dh1Z9E0Lm8XG)

![](/files/-MRxooc0TWzQPvB9n7U2)

![](/files/-MRxotLdsKhty-rTdSnA)

![](/files/-MRxowEu9gvG1tYIGrex)

![](/files/-MRxoyj7gJcBB3hKhsnS)

![](/files/-MRxp1tGNmLc2J6UrdfN)
