# 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/>

![](https://70217308-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LOrS79fMeCHu5s3Z1pa%2F-MRxnktiVcdWmuPB3_Ym%2F-MRxogu7Dh1Z9E0Lm8XG%2Fimage.png?alt=media\&token=8aca8e47-6b1b-44d6-9b0e-7c95e2772788)

![](https://70217308-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LOrS79fMeCHu5s3Z1pa%2F-MRxnktiVcdWmuPB3_Ym%2F-MRxooc0TWzQPvB9n7U2%2Fimage.png?alt=media\&token=ea41298e-54c4-4541-b0aa-c1bd8706522a)

![](https://70217308-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LOrS79fMeCHu5s3Z1pa%2F-MRxnktiVcdWmuPB3_Ym%2F-MRxotLdsKhty-rTdSnA%2Fimage.png?alt=media\&token=7c4675aa-e053-4062-8106-487a55c05011)

![](https://70217308-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LOrS79fMeCHu5s3Z1pa%2F-MRxnktiVcdWmuPB3_Ym%2F-MRxowEu9gvG1tYIGrex%2Fimage.png?alt=media\&token=12bcb303-4554-4c15-a9e2-190480750607)

![](https://70217308-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LOrS79fMeCHu5s3Z1pa%2F-MRxnktiVcdWmuPB3_Ym%2F-MRxoyj7gJcBB3hKhsnS%2Fimage.png?alt=media\&token=8e66ecd4-e353-4231-8929-1136eb10bf3d)

![](https://70217308-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LOrS79fMeCHu5s3Z1pa%2F-MRxnktiVcdWmuPB3_Ym%2F-MRxp1tGNmLc2J6UrdfN%2Fimage.png?alt=media\&token=38028407-8359-471b-b196-bb2ecd6fb48d)
