Motivation:
From the performance perspective, the TABLE generator has significant issues. It should be avoided.
150+ PERSISTENCE PERFORMANCE ITEMS
THAT WILL ROCK YOUR APPS
Description:
In MySQL & Hibernate 5/6, the GenerationType.AUTO generator type will result in using the TABLE generator. This adds a significant performance penalty. Turning this behavior to IDENTITY generator can be obtained by using GenerationType.IDENTITY or the native generator.
Key points:
Avoid GenerationType.AUTO (avoid the following code):
Prefer GenerationType.IDENTITY instead of GenerationType.AUTO:
Or, prefer the native generator:
Testing time:
Tam Ta Da Dam! :) The complete code is available on GitHub.
If you need a deep dive into the performance recipes exposed in this repository then I am sure that you will love my book "Spring Boot Persistence Best Practices".
Comments