2013-04-19 1 views
1

나는 다음과 같은 엔티티 TitleScreenFormat을 가지고 내가 entitymanager.commit 을 할 때 다음과 같은 오류중복 키 오류가 지속하는

Internal Exception: java.sql.SQLIntegrityConstraintViolationException: 
The statement was aborted because it would have caused a duplicate key 
value in a unique or primary key constraint or unique index identified 
by 'SQL130418144233630' defined on 'S1_TITLESCREENFORMAT'. Error Code: 
20000 Call: INSERT INTO s1_TitleScreenFormat 
(titlescreenformat_titleid, titlescreenformat_format, 
titlescreenformat_deliveryformat, TITLE_title_id) VALUES (?, ?, ?, ?) 
    bind => [TitleId1, Format1, DeliveryFormat1, null] 

보기이이 키를 사용하여 엔티티

@Entity 
    @Table(name = "s1_TitleScreenFormat") 
    public class TitleScreenFormat 
    { 
     @Id 
     @Column(name = "titlescreenformat_titleid", length = 128)  
     private String TitleId; 

     @Id 
     @Column(name = "titlescreenformat_deliveryformat", length = 128)  
     private String DeliveryFormat; 

     @Id 
     @Column(name = "titlescreenformat_format", length = 128)  
     private String Format; 


     private Title Title; 

그리고 이것은 내가 갖고 싶어하는 물건의 예입니다.

[0] TitleScreenFormat (id=81) 
    DeliveryFormat "DeliveryFormat1" (id=87) 
    Format "Format1" (id=88) 
    Title null  
    TitleId "TitleId1" (id=89) 
[1] TitleScreenFormat (id=83) 
    DeliveryFormat "DeliveryFormat2" (id=90) 
    Format "Format2" (id=91) 
    Title null  
    TitleId "TitleId2" (id=92) 
[2] TitleScreenFormat (id=84) 
    DeliveryFormat "DeliveryFormat3" (id=93) 
    Format "Format3" (id=94) 
    Title null  
    TitleId "TitleId3" (id=95) 
[3] TitleScreenFormat (id=85) 
    DeliveryFormat "DeliveryFormat4" (id=96) 
    Format "Format4" (id=97) 
    Title null  
    TitleId "TitleId4" (id=98) 
[4] TitleScreenFormat (id=86) 
    DeliveryFormat "DeliveryFormat5" (id=99) 
    Format "Format5" (id=100) 
    Title null  
    TitleId "TitleId5" (id=101) 
persistence.xml 파일에

나는 다음과 같은 구성을

<property name="eclipselink.ddl-generation" value="drop-and-create-tables" /> 

을 사용하여 임 더비 DB를 사용.

이 오류의 원인은 무엇입니까?

+1

glassfish와 같은 서버에 앱을 배포하고 있습니까? 그렇다면 Glassfish는 EclipseLink DDL 특성을 가로 채고 자체 Java2DB 기능을 사용하므로 작성된 스크립트와 로그를 점검하여 테이블이 예상대로 올바르게 h 제되었는지 확인하십시오. – Chris

+0

로깅을 활성화하고 테이블이 삭제되고 생성되고 중복 삽입이 일어나지 않는지 확인하십시오. – James

답변

0

DB에 동일한 값을 다시 삽입한다고 생각합니다. DB에 이미 존재하는 경우이 값을 유지하기 전에 DB에서 한 번만 확인하십시오.

또는이 값을 변경하고 다시 커밋 할 수 있습니다.

+0

그러나 drop과 create 테이블은 매번 새로운 인스턴스를 생성해야합니다 ... 당신은 생각하지 않습니까? –