// 버그가 해결 될 때까지 부모측에서 @org.hibernate.annotations.ForeignKey 를 함께 사용해야 한다.
// parent side
@OneToMany(
cascade = CascadeType.ALL,
fetch = FetchType.LAZY,
mappedBy = "parent",
orphanRemoval = true
)
// do not use a foreign key constraint, because it's not compatible with partitioning.
// needed on both sides of the relationship, but it doesn't look like jpa allows you
// to use @javax.persistence.ForeignKey on the mappedBy side, so we use deprecated hibernate
// version.
@org.hibernate.annotations.ForeignKey(name = "none")
public List<Child> getChildren() {
return _children;
}
// child side
@ManyToOne
@JoinColumn(
// do not use a foreign key constraint, because it's not compatible with partitioning
foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)
)
public Parent getParent() {
return _parent;
}