我正在学习JPA,我有一个名为User的实体类,它有两个另一个实体Car的列表,但是我不能让它与jpa一起工作。 这些类包含了所需的所有getter,setter和构造函数。
这是我的用户类:
@Entity
@Table(name = "Users")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(unique = true)
private String userName;
@OneToMany(i dont know what goes here as well)
private List<Car> owned;
@OneToMany( ?? )
private List<Car> rented;
这是我的Car类:
@Entity
@Table(name = "Cars")
public class Car implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne ( ?? )
private User owner;
我的两个问题是:
谢谢!