头像实体与联系人实体是双向一对一的关系,它的代码如下所示。
PortraitEO实体
@Entity
@Table(name = "tb_portrait")
public class PortraitEO implements java.io.Serializable {
public PortraitEO() {}
private Integer id;
/** 头像ID */
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
private Integer width;
/** 头像图片的宽 */
@Column(name = "width")
public Integer getWidth() {
return this.width;
}
public void setWidth(Integer width) {
this.width = width;
}
private Integer height;
/** 头像图片的高 */
@Column(name = "height")
public Integer getHeight() {
return this.height;
}
public void setHeight(Integer height) {
this.height = height;
}
private byte[] image;
/** 头像图片的字节数据 */
@Lob
@Basic(fetch = FetchType.LAZY)
@Column(name = "image")
public byte[] getImage() {
return image;
}
public void setImage(byte[] image) {
this.image = image;
}
private ContactEO contact;
/** 头像所属的联系人 */
@OneToOne(mappedBy = "portrait")
public ContactEO getContact() {
return contact;
}
public void setContact(ContactEO contact) {
this.contact = contact;
}
}