What are @Entity, @Id and @GeneratedValue for? Should you pick IDENTITY, SEQUENCE, UUID or AUTO?
Short answer
@Entity maps a class to a table, @Id marks the primary key, @GeneratedValue picks how ids are made. MySQL uses IDENTITY, PostgreSQL uses SEQUENCE; never leave AUTO on MySQL.
3 points to say:
IDENTITYis simple but loses batch inserts.SEQUENCEgrabs 50 ids at once, the fastest.AUTOon MySQL fakes a sequence with a table, slow.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.