문서의 선택한 두 판 사이의 차이를 보여줍니다.
마지막 판 양쪽 다음 판 | |||
java:jpa:index [2018/06/28 19:22] kwon37xi 만듦 |
java:jpa:index [2018/07/02 16:50] kwon37xi |
||
---|---|---|---|
줄 7: | 줄 7: | ||
* [[https:// | * [[https:// | ||
+ | |||
+ | ===== @ForeinKey ===== | ||
+ | * '' | ||
+ | * [[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; | ||
+ | } | ||
+ | </ | ||
+ |