© Anghel Leonard 2020
A. LeonardSpring Boot Persistence Best Practiceshttps://doi.org/10.1007/978-1-4842-5626-8_7

7. Identifiers

Anghel Leonard1 
(1)
Banesti, Romania
 

Item 65: Why to Avoid the Hibernate 5 AUTO Generator Type in MySQL

Consider the following Author entity, which relies on the Hibernate 5 AUTO generator type to generate identifiers:
@Entity
public class AuthorBad implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    // or
    @GeneratedValue
    private Long id;
    ...
}

In MySQL and Hibernate 5, the GenerationType.AUTO generator type will result in using the TABLE generator . This adds a significant performance penalty. The TABLE generator type doesn’t scale ...

Get Spring Boot Persistence Best Practices: Optimize Java Persistence Performance in Spring Boot Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.