Questions tagged «java-annotations»

3
注释@Id和@GeneratedValue(strategy = GenerationType.IDENTITY)的用途是什么?为什么世代类型是身份?
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) 为什么我们使用此注释?我需要知道这是否会自动增加我的表ID值。(GenerationType.IDENTITY)还有什么其他类型,当我们使用此批注时实际发生了什么 public class Author extends Domain { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id") private Integer id; @Basic(optional = false) @Column(name = "name") private String name; @Column(name = "address") private String address; @OneToMany(cascade = CascadeType.ALL, mappedBy = "authorId") private List<Book> bookList; public Author() …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.