Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 85366 invoked from network); 28 Dec 2007 18:15:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Dec 2007 18:15:48 -0000 Received: (qmail 13172 invoked by uid 500); 28 Dec 2007 18:15:37 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 13146 invoked by uid 500); 28 Dec 2007 18:15:37 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 13137 invoked by uid 99); 28 Dec 2007 18:15:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Dec 2007 10:15:37 -0800 X-ASF-Spam-Status: No, hits=3.2 required=10.0 tests=HTML_MESSAGE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [64.233.166.180] (HELO py-out-1112.google.com) (64.233.166.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Dec 2007 18:15:14 +0000 Received: by py-out-1112.google.com with SMTP id f47so6278644pye.8 for ; Fri, 28 Dec 2007 10:15:09 -0800 (PST) Received: by 10.35.96.6 with SMTP id y6mr11247894pyl.46.1198865709062; Fri, 28 Dec 2007 10:15:09 -0800 (PST) Received: by 10.35.38.11 with HTTP; Fri, 28 Dec 2007 10:15:09 -0800 (PST) Message-ID: Date: Fri, 28 Dec 2007 20:15:09 +0200 From: "Miroslav Nachev" To: users@openjpa.apache.org Subject: Cascade on Delete is not working MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_16909_29643510.1198865709054" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_16909_29643510.1198865709054 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I have 3 tables: - TestTable1 (test_table_1) which is master for the rest tables @Id @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 = "tt1Id") private Collection testTable2Collection; @OneToOne(cascade = CascadeType.ALL, fetch=FetchType.EAGER, mappedBy = "testTable1") private TestTable3 testTable3; - TestTable2 (test_table_2) @Id @Column(name = "tt2_id", nullable = false) private BigDecimal tt2Id; @JoinColumn(name = "tt1_id", referencedColumnName = "test_id") @ManyToOne private TestTable1 tt1Id; - TestTable3 (test_table_3) @Id @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) @OneToOne private TestTable1 testTable1; When I try to delete some record from TestTable1 I have the following exception: Caused by: 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? Miro. ------=_Part_16909_29643510.1198865709054--