2017-10-02 10 views
1

원인 최대 절전 모드에서. 최대 절전 모드 5에서 이것은 org.hibernate.exception.ConstraintViolationException: could not execute statement 오류로 인해 충돌합니다.우리는 <code>OneToOne</code> 양방향 관계를 ConstraintViolationException

"Show sql"을 활성화하면 트랜잭션 커밋에서 최대 절전 모드가 insert StudentState 쿼리를 insert Student 쿼리 전에 실행하려고 시도합니다. 그 원인은 다음과 같습니다.

Caused by: org.postgresql.util.PSQLException: 
ERROR: insert or update on table "studentstate" violates foreign key constraint "fk77j3mjaigcfotxlor35mdsl56"' 
Detail: Key (student)=(12) is not present in table "students". 

왜 이런 일이 발생했는지, 왜 이전에 작동했는지, 문제를 해결하는 방법에 대한 아이디어가 있습니까? TIA

+0

DB 스키마가 변경된 적이 있습니까? 제약 조건이 삽입시 확인되고 커밋되지 않은 것 같은데 ... –

+0

db 스키마가 동일합니다. 변경된 유일한 것은 최대 절전 모드 4 라이브러리가 최대 절전 모드 5와 종속성 (jpa, ehcache 등)으로 변경되었습니다. –

+0

최대 절전 모드가 일찍 완료되는 방법이 있습니까? –

답변

1

문제의 원인은 최대 절전 모드 코어의 버그입니다. org.hibernate.engine.spi.ActionQueue 클래스. 어린이를위한 어떤 경우에는 방법이 반대 값을 돌려 보는 것은 잘못 목록을 사용하여 위치를

 boolean hasAnyParentEntityNames(BatchIdentifier batchIdentifier) { 
      return parentEntityNames.contains(batchIdentifier.getEntityName()) 
        || parentEntityNames.contains(batchIdentifier.getRootEntityName()); 
     } 

     boolean hasAnyChildEntityNames(BatchIdentifier batchIdentifier) { 
      return childEntityNames.contains(batchIdentifier.getEntityName()) 
        || parentEntityNames.contains(batchIdentifier.getRootEntityName()); 
     } 

사람 : 여기

  boolean hasAnyParentEntityNames(BatchIdentifier batchIdentifier) { 
       return parentEntityNames.contains(batchIdentifier.getEntityName()) 
         || parentEntityNames.contains(batchIdentifier.getRootEntityName()); 
      } 

      boolean hasAnyChildEntityNames(BatchIdentifier batchIdentifier) { 
       return childEntityNames.contains(batchIdentifier.getEntityName()) 
         || childEntityNames.contains(batchIdentifier.getRootEntityName()); 
      } 

전에 있었던 코드 : 여기 내 수정 후 코드 .