사용자 도구

사이트 도구


java:jpa:index

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

다음 판
이전 판
java:jpa:index [2018/06/28 19:22]
kwon37xi 만듦
java:jpa:index [2019/04/10 16:16]
kwon37xi
줄 7: 줄 7:
  
   * [[https://docs.oracle.com/javaee/7/api/javax/persistence/ForeignKey.html|@javax.persistence.ForeignKey]] : ''@Join*'' 계통에서 FK 인덱스 정보 추가   * [[https://docs.oracle.com/javaee/7/api/javax/persistence/ForeignKey.html|@javax.persistence.ForeignKey]] : ''@Join*'' 계통에서 FK 인덱스 정보 추가
 +
 +===== @ForeinKey =====
 +  * ''@ForeinKey(ConstaintMode.NO_CONSTRAINT)''를 통해서 외래키를 의도적으로 생성하지 않을 수 있어야 한다.
 +  * [[java:hibernate|Hibernate]] 4.x, 5.x 일부에서 양방향(bidirectional) 관계에서 ''@ForeinKey(ConstaintMode.NO_CONSTRAINT)''가 먹지 않는 문제가 있다. - [[https://hibernate.atlassian.net/browse/HHH-8805|[HHH-8805] [SchemaUpdate] javax.persistence.ForeignKey doesn't respect ConstraintMode.NO_CONSTRAINT]]
 +    * 5.3.3, 5.4.0 에서 해결됨.
 +<code java>
 +// 버그가 해결 될 때까지 부모측에서 @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;
 +    }
 +</code>
 +
java/jpa/index.txt · 마지막으로 수정됨: 2019/04/10 16:16 저자 kwon37xi