Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 61477 invoked from network); 19 Sep 2009 20:06:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Sep 2009 20:06:22 -0000 Received: (qmail 58277 invoked by uid 500); 19 Sep 2009 20:06:22 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 58193 invoked by uid 500); 19 Sep 2009 20:06:22 -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 58183 invoked by uid 99); 19 Sep 2009 20:06:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Sep 2009 20:06:21 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of allee8285@gmail.com designates 209.85.221.193 as permitted sender) Received: from [209.85.221.193] (HELO mail-qy0-f193.google.com) (209.85.221.193) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Sep 2009 20:06:09 +0000 Received: by qyk31 with SMTP id 31so1279003qyk.9 for ; Sat, 19 Sep 2009 13:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=BNHLKnkTRSm7cyqXkZzXeOgqc3CvIsf7rmroab4ncak=; b=R83PswpL7cuLFb4QtTZlCeP0BL+kK2oHJeuY7T/l0RFlN9Z2sT+w9bPTx7NzwqIAj2 eEN31m/xG61gtpQtZyEatek/SZkLtAwxFXPjMGq5QJxHrVPwjFB049LlBkWSMoRXBlaV QzQA1UjAEEcO3kH5oE91Gj8gD8QH2WlZEzpjo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=dLORRzR9gZ2EWe7E8AUlpW6eZXx2UVw3RnBBiJSzhuqc/YBvH35tuMBQ9NnnoatakB gFl3gQaiYxvM3DlQbpw4wZXQjBv7zTLnh/NQQqS4Ry3/QVdjVtndzaFJqKpEEyW7sKmf rXl+us6KvZXIQlbi1HdI4Fpl+PEB8AL1nYXxw= MIME-Version: 1.0 Received: by 10.224.61.141 with SMTP id t13mr2415638qah.313.1253390748531; Sat, 19 Sep 2009 13:05:48 -0700 (PDT) Date: Sat, 19 Sep 2009 15:05:48 -0500 Message-ID: <8e68c8e90909191305g2ae1c293i5953d6ebc87ebac9@mail.gmail.com> Subject: @JoinTable not honor if "name" attribute is not specified From: Albert Lee To: open-jpa-dev Content-Type: multipart/alternative; boundary=00c09f9059d754bd210473f3c670 X-Virus-Checked: Checked by ClamAV on apache.org --00c09f9059d754bd210473f3c670 Content-Type: text/plain; charset=ISO-8859-1 If the name attribute of @JoinTable is not specified, join table is not created for entity relationship. E.g. @Entity public class LockScopeEntity1xm { @OneToMany(mappedBy="ownerOne") private Collection ownedMany = new HashSet(); @Entity public class LockScopeEntityMany { @JoinTable(name="xxx") @ManyToOne private LockScopeEntity1xm ownerOne; If name="xxx" is not specified, the following mapping is created: CREATE TABLE LockScopeEntity1xm (id INTEGER NOT NULL, version INTEGER, PRIMARY KEY (id)) CREATE TABLE LockScopeEntityMany (id INTEGER NOT NULL, version INTEGER, OWNERONE_ID INTEGER, PRIMARY KEY (id)) CREATE INDEX I_LCKSMNY_OWNERONE ON LockScopeEntityMany (OWNERONE_ID) Otherwise: CREATE TABLE LockScopeEntity1xm (id INTEGER NOT NULL, version INTEGER, PRIMARY KEY (id)) CREATE TABLE LockScopeEntityMany (id INTEGER NOT NULL, version INTEGER, PRIMARY KEY (id)) CREATE TABLE xxx (OWNEDMANY_ID INTEGER, OWNERONE_ID INTEGER) CREATE INDEX I_XXX_OWNEDMANY_ID ON xxx (OWNEDMANY_ID) CREATE INDEX I_XXX_OWNERONE ON xxx (OWNERONE_ID) However the spec spelled out the default in 11.1.23 that: @Target({METHOD, FIELD}) @Retention(RUNTIME) public @interface JoinTable { String name() default ""; ...... } Table 22 JoinTable Annotation Elements String | name | (Optional) The name of the join table. | Default: The concatenated names of the two associated primary entity tables (owning side first), separated by an underscore. Shouldn't in the case where name="xxx" is not specified the following mapping should be created? CREATE TABLE OWNEDMANY_OWNERONE (OWNEDMANY_ID INTEGER, OWNERONE_ID INTEGER) The setting of the join table name is in AnnotationPersisteneMappingParser private void parseJoinTable(FieldMapping fm, JoinTable join) { FieldMappingInfo info = fm.getMappingInfo(); info.setTableName(toTableName(join.schema(), join.name())); private static String toTableName(String schema, String table) { if (StringUtils.isEmpty(table)) return null; if (StringUtils.isEmpty(schema)) return table; return schema + "." + table; } If name is not specified, info.setTableName is set to null, that means no join table is used. Is this interpretation is correct? -- Albert Lee. --00c09f9059d754bd210473f3c670--