我试图让我的代码具有双向关系(一对一)但显然代码不起作用。
这里是头等舱。
public class User {
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "USER_PROFILE_FK")
private UserProfile userProfile;
//Accessor methods and other stuff
}
这是第二节课
@Entity
@Table(name ="USER_PROFILE")
public class UserProfile{
@OneToOne(mappedBy="UserProfile")
private User user;
//Accessor methods
}
现在,当我运行我的代码时,会发生此异常错误
Unknown mappedBy in: org.test.myApp.User, referenced property unknown: org.test.myApp.User.UserProfile