@Entity
@Table(name="CUSTOMERS") //Customer类和CUSTOMERS表映射
public class Customer implements java.io.Serializable {
@Id
@GeneratedValue(generator="increment")
@GenericGenerator(name="increment", strategy = "increment")
@Column(name="ID") //Customer类的id属性和CUSTOMERS表的ID字段映射
private Long id;
//Customer类的name属性和CUSTOMERS表的NAME字段映射
@Column(name="NAME")
private String name;
//Customer类的age属性和CUSTOMERS表的AGE字段映射
@Column(name="AGE")
private int age;
//Customer类与Order类一对多关联
@OneToMany(mappedBy="customer",
targetEntity=Order.class,
orphanRemoval=true,
cascade=CascadeType.ALL)
private Setorders = new HashSet();
……
} |