在一的一方 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192@Entity@Table(name = "T_CUSTOMER")public class Customer { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @Column(name = "LAST_NAME", length = 50, nullable = false) private String lastName; @Transient private String userinfo; //日期类型 @Temporal(TemporalType.DATE) private Date birth; //时间戳类型 @Temporal(TemporalType.TIMESTAMP) private Date createTime; @Temporal(TemporalType.TIMESTAMP) private Date updateTime; @Column(length =3) private Integer age; // 映射单向一对多的关联关系 @OneToMany @JoinColumn(name = "customer_id") private Set<Order> orders =new HashSet<Order>(); public Set<Order> getOrders() { return orders; } public void setOrders(Set<Order> orders) { this.orders = orders; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getUserinfo() { return userinfo; } public void setUserinfo(String userinfo) { this.userinfo = userinfo; } public Date getBirth() { return birth; } public void setBirth(Date birth) { this.birth = birth; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; }} 在多的一方 123456789101112131415161718192021222324252627@Entity@Table(name = "t_order")public class Order { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String name; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; }}