MySQL
CREATE TABLE `role` ( `id_role` INT(11) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id_role`) ) AUTO_INCREMENT=1;
Sleep mode
@Entity public class Role { private Integer idRole; @Column(name = "id_role", precision = 10) @GeneratedValue @Id public Integer getIdRole() { return idRole; } public void setIdRole(Integer idRole) { this.idRole = idRole; } }
Given the above background, who is responsible for automatically increasing the id_role column when creating a new role ? In other words, does Hibernate set the primary key value before running the create SQL statement or set it to null and allows MySQL to automatically increase the field when the selected primary key returns?
sp00m source share