From dev-return-5192-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Tue Jul 31 19:36:27 2007 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 3722 invoked from network); 31 Jul 2007 19:36:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 31 Jul 2007 19:36:26 -0000 Received: (qmail 36763 invoked by uid 500); 31 Jul 2007 19:36:13 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 36735 invoked by uid 500); 31 Jul 2007 19:36:13 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 36714 invoked by uid 99); 31 Jul 2007 19:36:13 -0000 Received: from Unknown (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Jul 2007 12:36:13 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Jul 2007 19:36:13 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id C745E7141F0 for ; Tue, 31 Jul 2007 12:35:52 -0700 (PDT) Message-ID: <32112530.1185910552813.JavaMail.jira@brutus> Date: Tue, 31 Jul 2007 12:35:52 -0700 (PDT) From: "Markus Fuchs (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Commented: (OPENJPA-177) When using NOT NULL constraint on foreign key it is not possible to use CascadeType.ALL and GeneratedId MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12516785 ] Markus Fuchs commented on OPENJPA-177: -------------------------------------- This problem should be solved by openjpa-235-break-nullable.patch, which has been checked in. > When using NOT NULL constraint on foreign key it is not possible to use CascadeType.ALL and GeneratedId > ------------------------------------------------------------------------------------------------------- > > Key: OPENJPA-177 > URL: https://issues.apache.org/jira/browse/OPENJPA-177 > Project: OpenJPA > Issue Type: Bug > Components: jpa > Affects Versions: 0.9.6 > Environment: Windows XP, IBM 32-bit SDK 5.0, WebSphere 6.1 > Reporter: Daniel Gajdos > > When using on entity Application > @OneToOne(cascade = CascadeType.ALL) > @JoinColumn(name = "C_PERSON_ID", nullable=false) > @ForeignKey > private Person person; > and on entity Person using generated ID, it fails on inserting Application because of performing db actions in this order: > INSERT INTO T_APPLICATION (C_ID, C_APPLICATION_NUMBER, C_APPLIED_DATE, C_STATUS) VALUES (:1, :2, :3, :4) - here it tries to insert null value as C_PERSON_ID, which is not permited because of nullable=false declaration. This declaration creates NOT NULL constraint on C_PERSON_ID. > INSERT INTO NSVISP.T_PERSON (C_ID, C_BIRTH_DATE, C_FIRST_NAME, C_LAST_NAME) VALUES (:1, :2, :3, :4) > UPDATE NSVISP.T_APPLICATION SET C_PERSON_ID = :1 WHERE C_ID = :2 > Error reported from DB: > org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-01400: cannot insert NULL into ("T_APPLICATION"."C_PERSON_ID") > Is there any chance to change the order in which this operations are executed? On this type of constraint we have to insert Person before inserting Application and include the generated Person Id into insert statement for Application. Otherwise we have to deffer the NOT NULL constraint which can be dangerous and it is not defered initialy. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.