一、@Entity
写在映射表的类上面,表示这是映射来的实体
二、@Id
@Column(name = "fid", nullable = false)
@Basic
@Column(name = "fname", nullable = true, length = 10)
四、@OneToMany(mappedBy = "father",cascade = {CascadeType.ALL})(父亲端)
@ManyToOne
@JoinColumn(name = "fid", referencedColumnName = "fid")(儿子端)
写在一对多的外键属性上,儿子那个属性被定义为一个set集。
五、@OneToOne(cascade ={CascadeType.ALL})(all代表各种操作一个丈夫,都会关联到妻子)
@JoinColumn(name = "id", referencedColumnName = "id", nullable = false)(丈夫端)
@OneToOne
@JoinColumn(name = "id", referencedColumnName = "id", nullable = false)
写在一对一的外键属性上,都定义为一个String属性了。
六、@Cascade(value=org.hibernate.annotations.CascadeType.SAVE_UPDATE)
@ManyToMany()
@JoinTable(name = "teastu", catalog = "res", schema = "res", joinColumns = @JoinColumn(name = "tid", referencedColumnName = "tid", nullable = false), inverseJoinColumns = @JoinColumn(name = "sid", referencedColumnName = "sid", nullable = false))(老师端)
@ManyToMany(mappedBy = "stus")(学生端)
写在多对多的外键属性上。