Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 15175 invoked from network); 10 Mar 2009 15:09:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Mar 2009 15:09:15 -0000 Received: (qmail 42122 invoked by uid 500); 10 Mar 2009 15:09:14 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 42091 invoked by uid 500); 10 Mar 2009 15:09:14 -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 42080 invoked by uid 99); 10 Mar 2009 15:09:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Mar 2009 08:09:14 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Mar 2009 15:09:11 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 97E39234C004 for ; Tue, 10 Mar 2009 08:08:50 -0700 (PDT) Message-ID: <270153767.1236697730617.JavaMail.jira@brutus> Date: Tue, 10 Mar 2009 08:08:50 -0700 (PDT) From: "Tim McConnell (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Assigned: (OPENJPA-510) ReverseMappingTool generates incorrect SQL for PostgreSQL if -fk = true In-Reply-To: <2745261.1202272508313.JavaMail.jira@brutus> 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-510?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Tim McConnell reassigned OPENJPA-510: ------------------------------------- Assignee: Tim McConnell > ReverseMappingTool generates incorrect SQL for PostgreSQL if -fk = true > ----------------------------------------------------------------------- > > Key: OPENJPA-510 > URL: https://issues.apache.org/jira/browse/OPENJPA-510 > Project: OpenJPA > Issue Type: Bug > Components: jdbc > Affects Versions: 1.1.0 > Environment: PostgreSQL > Reporter: Michael Dick > Assignee: Tim McConnell > > Opening on behalf of Tim Holloway per email to the OpenJPA mailing list. > Synopsis: Invalid code is generated when internally-generated foreign > key names are used and the ReverseMappingTool is run with the "-fk" > option set to true. > Description: If a constraint name is not explicitly defined, PostgreSQL > v7 synthesizes constraint names in the form "$n", where n is numeric, > viz: > Table "public.bus_stops" > Column | Type | Modifiers > -------------------+-----------------------+------------------------ > stop_id | integer | not null > street1_name | character varying(32) | not null > street1_qualifier | character varying(11) | > street1_block | integer | > street2_name | character varying(32) | > street2_qualifier | character varying(11) | > street2_block | integer | > longitude | numeric(16,8) | not null default 0.0 > latitude | numeric(16,8) | not null default 0.0 > elevation | numeric(16,8) | not null default 0.0 > description | text | > sheltered | boolean | not null default false > inbound | boolean | not null > street1_type | character varying(8) | not null > street2_type | character varying(8) | not null > street1_direction | character varying(5) | not null > street2_direction | character varying(5) | not null > Indexes: > "stop2_pkey" primary key, btree (stop_id) > Foreign-key constraints: > "$1" FOREIGN KEY (street1_direction) REFERENCES > lk_street_directions(street_direction_id) > "$2" FOREIGN KEY (street2_direction) REFERENCES > lk_street_directions(street_direction_id) > "fk_bus_stops_street1_type" FOREIGN KEY (street1_type) REFERENCES > lk_street_types(street_type_id) > "fk_bus_stops_street2_type" FOREIGN KEY (street2_type) REFERENCES > lk_street_types(street_type_id) > Consequences: Note the generated code for synthesized and explicit > constraint names: > /** > * Auto-generated by: > * org.apache.openjpa.jdbc.meta.ReverseMappingTool > $AnnotatedCodeGenerator > */ > @Entity > @Table(schema="public", name="bus_stops") > public class BusStops { > @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE) > @JoinColumn(name="street1_direction", nullable=false) > private LkStreetDirections 1; //<==== WRONG > @OneToMany(targetEntity=com.mousetech.jta.persist.TripStops.class, > mappedBy="1", cascade=CascadeType.MERGE) > //VVVVV WRONG VVVV > private Set 1Inverses = new HashSet(); > @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE) > @JoinColumn(name="street2_direction", nullable=false) > private LkStreetDirections 2; //<==== WRONG > @OneToMany(targetEntity=com.mousetech.jta.persist.RouteStops.class, > mappedBy="2", cascade=CascadeType.MERGE) > //VVVVV WRONG VVVV > private Set 22Inverses = new HashSet(); > @Basic > @Column(columnDefinition="text", length=2147483647) > private String description; > @Basic > private double elevation; > @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE) > @JoinColumn(name="street1_type", nullable=false) > private LkStreetTypes fkBusStopsStreet1Type; //<==== CORRECT > @ManyToOne(fetch=FetchType.LAZY, cascade=CascadeType.MERGE) > @JoinColumn(name="street2_type", nullable=false) > private LkStreetTypes fkBusStopsStreet2Type; //<==== CORRECT > (remainder of code omitted as immaterial). -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.