Spring JPA annotation 한 쌍 이 많 고 한 쌍 이 많은 고민 들
Channel. class 부모 클래스
@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "channel")
private List<Content> contentList;
public List<Content> getContentList() {
return contentList;
}
public void setContentList(List<Content> contentList) {
this.contentList = contentList;
}
Content. class 하위 클래스
@ManyToOne
@JoinColumn(name = "channelId", insertable = false, updatable = false)
private Channel channel;
public Channel getChannel() {
return channel;
}
public void setChannel(Channel channel) {
this.channel = channel;
}
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
@Id get ,
jpa ,
@Entity
@Table
@GeneratedValue auto
uuid , jpa , hibernate
:
@GenericGenerator(name="idGenerator", strategy="uuid") // hibernate
@GeneratedValue(generator="idGenerator") // uuid
@Column(name="username", nullable=false, unique=true, length=30) , , 30
@Transient
hibernate JPA
@ManyToOne
, JPA + "_" + "id" .
mappedBy ,
hibernate inverse=true
@OneToMany
mappedBy
JoinColumn
TargetEntity
manyToMany
@JoinTable