From open-jpa-dev-return-2696-apmail-incubator-open-jpa-dev-archive=incubator.apache.org@incubator.apache.org Tue Mar 13 18:26:44 2007 Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 49920 invoked from network); 13 Mar 2007 18:26:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Mar 2007 18:26:43 -0000 Received: (qmail 67888 invoked by uid 500); 13 Mar 2007 18:26:40 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 67854 invoked by uid 500); 13 Mar 2007 18:26:40 -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 67763 invoked by uid 99); 13 Mar 2007 18:26:40 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Mar 2007 11:26:39 -0700 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; Tue, 13 Mar 2007 11:26:29 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 49BF171406F for ; Tue, 13 Mar 2007 11:26:09 -0700 (PDT) Message-ID: <29200918.1173810369270.JavaMail.jira@brutus> Date: Tue, 13 Mar 2007 11:26:09 -0700 (PDT) From: "Abe White (JIRA)" To: open-jpa-dev@incubator.apache.org Subject: [jira] Commented: (OPENJPA-171) EntityManager.getReference() returns an object of a wronc class In-Reply-To: <12197142.1173795729281.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-171?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480510 ]=20 Abe White commented on OPENJPA-171: ----------------------------------- I attempted to reproduce this in a very simple test case but failed. We'll= need a user-supplied test case. As a technical aside, I'm having trouble = seeing how the "T getReference(Class cls, Object id)" method could possi= bly return anything other than a "T" instance. > EntityManager.getReference() returns an object of a wronc class > --------------------------------------------------------------- > > Key: OPENJPA-171 > URL: https://issues.apache.org/jira/browse/OPENJPA-171 > Project: OpenJPA > Issue Type: Bug > Affects Versions: 0.9.6 > Reporter: Stefano Juri > > I have a simple class system : a PersonImpl owns a set of AbstractAddress= es. An AbstractAddress can be an EMailAddressImpl or a PostalAddressImpl. A= ll these objects extend AbstractBusinessObject.=20 > When I call entityManager.getReference(PersonImpl.class, "1") I get the E= MailAddressImpl object with id "1" instead of a PersonImpl object.=20 > If I get the object with a query (select p from PersonImpl p where p.id= =3D'1') everything is ok. > My mapping file is :=20 > =09xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" > =09xsi:schemaLocation=3D"http://java.sun.com/xml/ns/persistence/orm http:= //java.sun.com/xml/ns/persistence/orm_1_0.xsd" > =09version=3D"1.0"> > =09 =09=09class=3D"ch.admin.bit.fw2.bm.AbstractBusinessObjectImpl"> > =09=09 > =09=09=09 > =09=09=09=09 > =09=09=09=09 > =09=09=09=09 > =09=09=09 > =09=09=09 > =09=09 > =09 > =09 > =09 > =09=09
> =09=09 > =09=09 > =09=09 > =09=09=09 > =09=09=09=09 > =09=09=09 > =09=09 > =09
> =09 > =09 > =09=09E > =09=09 > =09=09=09 > =09=09=09=09 > =09=09=09 > =09=09=09 > =09=09=09=09 > =09=09=09 > =09=09 > =09 > =09 > =09 > =09=09P > =09=09 > =09=09=09 > =09=09=09=09 > =09=09=09 > =09=09=09 > =09=09=09=09 > =09=09=09 > =09=09=09 > =09=09=09 > =09=09=09 > =09=09=09 > =09=09 > =09 > =09 > =09 > =09=09 > =09=09 > =09=09=09 > =09=09=09 > =09=09=09=09 > =09=09=09 > =09=09=09 > =09=09=09=09 > =09=09=09 > =09=09=09 =09=09=09=09target-entity=3D"ch.admin.bit.fw2.demo.bm.address.AbstractAdd= ressImpl"> > =09=09=09=09 > =09=09=09=09=09 > =09=09=09=09=09 > =09=09=09=09 > =09=09=09 > =09=09 > =09 > =09 > > And the database creation script is : > -------------------------------------------------- > -- Create Table ADDRESS > -------------------------------------------------- > Create table ADDRESS ( > ID VARCHAR(20) NOT NULL , > DISCRIMINANT CHARACTER(1) NOT NULL , > ADDRESS_NAME VARCHAR(35) NOT NULL , > EMAIL_DOMAIN VARCHAR(50) , > EMAIL_NAME VARCHAR(50) , > FIRST_NAME VARCHAR(35) , > LAST_NAME VARCHAR(35) , > STREET VARCHAR(35) , > CITY VARCHAR(35) , > ZIP VARCHAR(10) , > COUNTRY CHARACTER(2) , > VERSION TIMESTAMP > ) > ; > -------------------------------------------------- > -- Create Primary Key PRIMARY_KEY > -------------------------------------------------- > alter table ADDRESS=20 > =09add constraint PERSON_KEY=20 > =09Primary Key (ID); > -------------------------------------------------- > -- Create Table PERSON > -------------------------------------------------- > Create table PERSON ( > ID VARCHAR(20) NOT NULL , > FIRST_NAME VARCHAR(35) NOT NULL , > LAST_NAME VARCHAR(35) NOT NULL , > TITLE VARCHAR(35) NOT NULL , > VERSION TIMESTAMP > )=20 > ; > -------------------------------------------------- > -- Create Primary Key SQL060816161507820 > -------------------------------------------------- > alter table PERSON=20 > =09add constraint ADDRESS_KEY=20 > =09Primary Key (ID); > =09 > -------------------------------------------------- > -- Create Table PERS_ADDR > -------------------------------------------------- > Create table PERS_ADDR ( > ID_PERSON VARCHAR(20) NOT NULL , > ID_ADDRESS VARCHAR(20) NOT NULL =20 > ); > -------------------------------------------------- > -- Create Primary Key SQL060816161507820 > -------------------------------------------------- > alter table PERS_ADDR=20 > =09add constraint PERS_ADDR_KEY=20 > =09Primary Key (ID_PERSON,ID_ADDRESS); > =09 > Insert into PERSON values('1', 'Enrico', 'Barilla', 'Mr',0); > Insert into PERSON values('2', 'Adelgrunde', 'Volkswagen', 'Ms',0);=09 > =09 > Insert into ADDRESS values('1', 'E', 'Home', 'barilla.it', 'enrico.barill= a', NULL, NULL, NULL, NULL, NULL, NULL, 0); > Insert into ADDRESS values('2', 'P', 'Office', NULL, NULL, NULL, NULL, 'K= =C3=A4ferstr. 78', 'Wolfsburg', '12345', 'DE', 0); > Insert into ADDRESS values('3', 'P', 'Home', NULL, NULL, NULL, NULL, 'Via= delle Lasagne 12', 'Roma', '67890', 'IT', 0); > Insert into PERS_ADDR values ('1','1'); > Insert into PERS_ADDR values ('1','3'); > Insert into PERS_ADDR values ('2','2'); --=20 This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.