Reputation: 16127
I am trying to make my code have a bidrectional relationship(One TO One) But apparently the code is not working.
here's the First Class.
public class User {
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "USER_PROFILE_FK")
private UserProfile userProfile;
//Accessor methods and other stuff
}
and this is the second class
@Entity
@Table(name ="USER_PROFILE")
public class UserProfile{
@OneToOne(mappedBy="UserProfile")
private User user;
//Accessor methods
}
Now when I run my code this exception error occurs
Unknown mappedBy in: org.test.myApp.User, referenced property unknown: org.test.myApp.User.UserProfile
Upvotes: 1
Views: 1898
Reputation: 691785
The field at the other side of the association is named userProfile
, not UserProfile
, so the mappedBy attribute must be set to userProfile
.
Upvotes: 3