내용으로 건너뛰기
권남
사용자 도구
로그인
사이트 도구
검색
도구
문서 보기
이전 판
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
추적:
java:jpa:index
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
====== JPA and Index ====== * JPA 2.1 부터 Table Index 설정을 애노테이션으로 할 수 있게 되었다. ===== @Annotations ===== * [[https://docs.oracle.com/javaee/7/api/javax/persistence/UniqueConstraint.html|@javax.persistence.UniqueConstraint]] : ''@Table'' 애노테이션에서 Unique index를 걸 수 있다. * [[https://docs.oracle.com/javaee/7/api/javax/persistence/Index.html|@javax.persistence.Index]] : ''@Table'' 계통 애노테이션에서 Index 추가 가능 * [[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
문서 도구
문서 보기
이전 판
역링크
맨 위로