Hi All, In one to one mapping is it ok to add column foreign key in parent like
@Entity(name = "Post")
@Table(name = "post")
public class Post {
@Id
@GeneratedValue
private Long id;
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "postDetails_id")
private PostDetails postDetails;
}
@Entity(name = "PostDetails")
@Table(name = "post_details")
public class PostDetails {
@Id
@GeneratedValue
private Long id;
@OneToOne(mappedBy = "postDetails")
private Post post;
}
Rather then
Setting foreign key in post_details table (i.e post_id)
@Entity(name = "PostDetails")
@Table(name = "post_details")
public class PostDetails {
@Id
@GeneratedValue
private Long id;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "post_id")
private Post post;
}