Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 99673 invoked from network); 15 Feb 2007 14:40:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Feb 2007 14:40:27 -0000 Received: (qmail 46745 invoked by uid 500); 15 Feb 2007 14:40:34 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 46636 invoked by uid 500); 15 Feb 2007 14:40:34 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 46625 invoked by uid 99); 15 Feb 2007 14:40:34 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Feb 2007 06:40:34 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= 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; Thu, 15 Feb 2007 06:40:25 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 8A3637140D1 for ; Thu, 15 Feb 2007 06:40:05 -0800 (PST) Message-ID: <6219061.1171550405563.JavaMail.jira@brutus> Date: Thu, 15 Feb 2007 06:40:05 -0800 (PST) From: "Albert Lee (JIRA)" To: open-jpa-dev@incubator.apache.org Subject: [jira] Created: (OPENJPA-150) @Column in @AttributeOverride not honoring table attribute that maps to a secondary table in mappedsuperclass entity MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org @Column in @AttributeOverride not honoring table attribute that maps to a secondary table in mappedsuperclass entity -------------------------------------------------------------------------------------------------------------------- Key: OPENJPA-150 URL: https://issues.apache.org/jira/browse/OPENJPA-150 Project: OpenJPA Issue Type: Bug Components: jdbc, sql Environment: Any Reporter: Albert Lee I have the following scenario mapping entity to 2 tables: - a mapped super class that has a field - a subclass with a pk and a field. - trying to map all the fields (except the pk (id) ) to a secondary table (SEC_TABLE2MSC) - use @Column in the sub-class to override (name) to the secondary table - use @AttributeOverride to override the field (street) in the mapped super class to the secondary table. =============== @MappedSuperclass public abstract class AnnMSCMultiTable implements IMultiTableEntity { // @Column(table="SEC_TABLE2MSC") private String street; public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } } =============== @Entity @SecondaryTable(name="SEC_TABLE2MSC", pkJoinColumns=@PrimaryKeyJoinColumn(name="id")) @AttributeOverrides( { @AttributeOverride(name="street", column=@Column(name="street", table="SEC_TABLE2MSC")), }) public class AnnMSCMultiTableEnt extends AnnMSCMultiTable { @Id private int id; @Column(name="name2", table="SEC_TABLE2MSC") private String name; } =============== >From examining JPA spec, there is no specific in the @Column and @AttributeOverride that this should not be allow. So I believe this is a valid scenario. Using the MappingTool, the attribute override does not map the street field to the SEC_TABLE2MSC as I would expect: CREATE TABLE AnnMSCMultiTableEnt (id INTEGER NOT NULL, street VARCHAR(254), PRIMARY KEY (id)); CREATE TABLE SEC_TABLE2MSC (id INTEGER, name2 VARCHAR(254)); CREATE INDEX I_SC_TMSC_ID ON SEC_TABLE2MSC (id); I experiment this a little bit and the only way I can map the street field to SEC_TABLE2MSC is to add the @Column against the "street" attribute in the super class. (the commented @Column in the example). The expected SQL are: CREATE TABLE AnnMSCMultiTableEnt (id INTEGER NOT NULL, PRIMARY KEY (id)); CREATE TABLE SEC_TABLE2MSC (id INTEGER, street VARCHAR(254), name2 VARCHAR(254)); CREATE INDEX I_SC_TMSC_ID ON SEC_TABLE2MSC (id); I tried to create the tables manually using the expected layout, but the runtime still using the incorrect tables structure. I would suspect the MappingTool and the runtime are using the same mapping strategy. Albert Lee, -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.