@注解配置实体类映射
实体一般有id,普通属性,集合属性等,分别对应数据库中的主键,普通列,外键。@注解配置中,实体类@Entity注解,用@Table指定对应的数据表,@Id配置主键。用@Column配置普通属性,用@OneToMany、@ManyToOne、@OneToOne、@ManyToMany配置实体间的关系等。
//...导入一系列包<省略>@Entity@Table(name = “tb_cat”)public class Cat{@Id@GeneratedValue(String = GenerationType.AUTO)private Integer id;@Column(name = “name”)private String name;@Temporal(TemporalType.TIMESTAMP)@Column(name = “createDate”)private Timestamp createDate; //….getter、setter方法省略}