MySQL
CREATE TABLE `role` (
`id_role` INT(11) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id_role`)
) AUTO_INCREMENT=1;
休眠
@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;
}
}
鉴于上述背景,谁负责id_role
在创建新列时自动增加列role
?换句话说,Hibernate 是在运行create
SQL 语句之前设置主键值,还是将其设置为null
并让 MySQL 在取回所选主键时自动递增字段?