MySql JPA toplink Auto increment id generation.
To configure JPA entity to make use of auto increment feature of MySql for primary key generation you can make use of IDENTITY strategy ref below code.
@Entity public class Customer { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private long id; . . . public long getId() { return id; } } But problem with this way of generating ids with MySql and JPA combination is when you persist new entity and try to retrieve id assigned to newly persisted entity using getId() method.
[Read More]