문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 다음 판 | 이전 판 | ||
|
java:jpa:index [2018/06/28 19:22] kwon37xi 만듦 |
java:jpa:index [2019/04/10 16:16] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 7: | 줄 7: | ||
| * [[https:// | * [[https:// | ||
| + | |||
| + | ===== @ForeinKey ===== | ||
| + | * '' | ||
| + | * [[java: | ||
| + | * 5.3.3, 5.4.0 에서 해결됨. | ||
| + | <code java> | ||
| + | // 버그가 해결 될 때까지 부모측에서 @org.hibernate.annotations.ForeignKey 를 함께 사용해야 한다. | ||
| + | // parent side | ||
| + | @OneToMany( | ||
| + | cascade = CascadeType.ALL, | ||
| + | fetch = FetchType.LAZY, | ||
| + | mappedBy = " | ||
| + | orphanRemoval = true | ||
| + | ) | ||
| + | // do not use a foreign key constraint, because it's not compatible with partitioning. | ||
| + | // needed on both sides of the relationship, | ||
| + | // to use @javax.persistence.ForeignKey on the mappedBy side, so we use deprecated hibernate | ||
| + | // version. | ||
| + | @org.hibernate.annotations.ForeignKey(name = " | ||
| + | public List< | ||
| + | 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; | ||
| + | } | ||
| + | </ | ||
| + | |||