I don't understand why this code create OneToMany instead of OneToOne Can somebody tell where i made mistake. I have got 2 class:
@Entity
@Table(name = "user")
public class User {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(unique=true)
@Id
private String login;
private String password;
private String firstName;
private String lastName;
private String city;
private int age;
private Sex sex ;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "user", cascade = CascadeType.ALL)
//@JoinColumn(name= "user_details")
private UserProfile userProfile;
Second class:
@Entity
@Table(name = "user_profile")
public class UserProfile {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long Id;
@Id
private String user_login;
private String user_interestings;
@OneToOne//mappedBy= "userProfile")
@MapsId
private User user;
Here is image, how it end in MySQLWOrkbench enter image description here
Thanks for help.