From dev-return-20057-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Fri Feb 3 16:24:30 2012 Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8D5AB909C for ; Fri, 3 Feb 2012 16:24:30 +0000 (UTC) Received: (qmail 52302 invoked by uid 500); 3 Feb 2012 16:24:30 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 52259 invoked by uid 500); 3 Feb 2012 16:24:29 -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 52251 invoked by uid 99); 3 Feb 2012 16:24:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Feb 2012 16:24:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Feb 2012 16:24:27 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 26CBB18BAA9 for ; Fri, 3 Feb 2012 16:24:06 +0000 (UTC) Date: Fri, 3 Feb 2012 16:24:06 +0000 (UTC) From: "Albert Lee (Updated) (JIRA)" To: dev@openjpa.apache.org Message-ID: <1803515117.7893.1328286246160.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (OPENJPA-1057) Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-1057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Albert Lee updated OPENJPA-1057: -------------------------------- Affects Version/s: 2.2.0 2.1.1 Fix Version/s: (was: 2.2.0) 2.3.0 Move fix version to 2.3.0 in-preparation for 2.2.0 release. > Foreign keys are not properly set for ConstraintUpdateManager to determine the correct order of the sql > ------------------------------------------------------------------------------------------------------- > > Key: OPENJPA-1057 > URL: https://issues.apache.org/jira/browse/OPENJPA-1057 > Project: OpenJPA > Issue Type: Bug > Components: jdbc > Affects Versions: 2.0.0-M2, 2.1.1, 2.2.0 > Reporter: Fay Wang > Assignee: Fay Wang > Fix For: 2.3.0 > > Attachments: OPENJPA-1057.patch > > > In the following situations, foreign keys are not properly set in the RowImpl for ConstraintUpdateManager to correctly determine the order of sql: > (1) bottom-up table creation for primary table and secondary table with foreign key referencing the primary table: Both primary and secondary tables are used to store the data in an entity, which has the annotation as below: > @Table(name="Tbl1") > @SecondaryTable(name="Tbl2",pkJoinColumns=@PrimaryKeyJoinColumn(name="ID")) > public class EntityA implements Serializable { > > ... > } > In this situation, Openjpa fails to record the foreign key information in the secondary row. Without the foreign key constraint information, the ConstraintUpdateManager is unable to determine the ordering correctly. > (2) bottom up table creation for an entity and its toOne/toMany relation with foreign key constraint. For example: > create table Bidir1to1A (id integer not null, age integer not null, name varchar(30), primary key (id)); > create table Bidir1to1B (id integer not null, name varchar(30), entitya_id integer, primary key (id)); > alter table Bidir1to1B add constraint FK452ACC2BD7410520 foreign key (entitya_id) references Bidir1to1A; > In this situation, Openjpa reads in the database foreign key constraint. If the relation field does not have ForeignKey annotation, or the ForeignKey annotation has deleteAction set to DEFAULT: > @OneToOne(cascade=CascadeType.REMOVE) > @ForeignKey(deleteAction=ForeignKeyAction.DEFAULT) > public Unidir1to1B entityb; > this foreign key constraint will not be recorded in the RowImpl due to the deleteAction = ForeignKey.ACTION_NONE. The lack of foreign key constraint information in the RowImpl leads to the wrong ordering of the sql by the ConstraintUpdateManager. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira