Assuming 2 entities are related in one-to-one relationship - Post and PostDetail.
Looking at the DDL Preview in Studio, Post_ID in PostDetail is a FK to Post entity but it’s not indexed. I need to access PostDetail row for each Post row, so will need to have the index on Post_ID in PostDetail. How can i achieve this? Thanks for any advice.
Source of the 2 entities is attached.
@NamePattern("%s|title")
@Table(name = "ONEONE_POST")
@Entity(name = "oneone$Post")
public class Post extends StandardEntity {
private static final long serialVersionUID = -91728454289812375L;
@Column(name = "TITLE")
protected String title;
@OneToOne(fetch = FetchType.LAZY, mappedBy = "post")
protected PostDetail postDetail;
public void setPostDetail(PostDetail postDetail) {
this.postDetail = postDetail;
}
public PostDetail getPostDetail() {
return postDetail;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
}
@Table(name = "ONEONE_POST_DETAIL")
@Entity(name = "oneone$PostDetail")
public class PostDetail extends StandardEntity {
private static final long serialVersionUID = 8117802680365648674L;
@Column(name = "CONTENT")
protected String content;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "POST_ID")
protected Post post;
public void setContent(String content) {
this.content = content;
}
public String getContent() {
return content;
}
public void setPost(Post post) {
this.post = post;
}
public Post getPost() {
return post;
}
}