注解实体映射

user.java:

@OneToMany(targetEntity = TOrder.class, cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "user")
private Set orders = new HashSet();

private String password;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
//@SequenceGenerator(name="userGenerator",sequenceName="user_seq",initialValue=1,allocationSize=1)
//@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="userGenerator")
private Integer userId;

@Column(name = "userName", length = 50, nullable = false)
private String userName;



Order.java:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer orderId;
// 多对一
// private Integer userId;
@ManyToOne(targetEntity=TUser.class)
@JoinColumn(name="userId")
private TUser user;
private Double totalMoney;
@Temporal(value = TemporalType.TIMESTAMP)
private Date orderDate;

你可能感兴趣的:(注解)