openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Miroslav Nachev" <>
Subject Cascade on Delete is not working
Date Fri, 28 Dec 2007 18:15:09 GMT

I have 3 tables:
- TestTable1 (test_table_1) which is master for the rest tables
    @Column(name = "test_id", nullable = false)
    private BigDecimal testId;
    @Column(name = "is_deleted", nullable = false)
    private boolean deleted;
    @OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER, mappedBy =
    private Collection<TestTable2> testTable2Collection;
    @OneToOne(cascade = CascadeType.ALL, fetch=FetchType.EAGER, mappedBy =
    private TestTable3 testTable3;

- TestTable2 (test_table_2)
    @Column(name = "tt2_id", nullable = false)
    private BigDecimal tt2Id;
    @JoinColumn(name = "tt1_id", referencedColumnName = "test_id")
    private TestTable1 tt1Id;
- TestTable3 (test_table_3)
    @Column(name = "tt3_id", nullable = false)
    private BigDecimal tt3Id;
    @Column(name = "text_data")
    private String textData;
    @JoinColumn(name = "tt3_id", referencedColumnName = "test_id",
insertable = false, updatable = false)
    private TestTable1 testTable1;

When I try to delete some record from TestTable1 I have the following
Caused by: <openjpa-1.1.0-SNAPSHOT-r420667:606946M nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: ERROR: update or delete
on table "test_table_1" violates foreign key constraint "fk_tt2_tt1_id" on
table "test_table_2"
  Detail: Key (test_id)=(1198864038296) is still referenced from table
"test_table_2". {prepstmnt 25877218 DELETE FROM test_table_1 WHERE test_id =
? [params=(BigDecimal) 1198864038296]} [code=0, state=23503]

Where did I go wrong? Why I can not delete record from master table and all
records from referenced tables to be cascade deleted?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message