[jira] Commented: (OPENJPA-171) EntityManager.getReference() returns an object of a wronc class

2007-03-13 Thread Abe White (JIRA)

[ 
https://issues.apache.org/jira/browse/OPENJPA-171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480455
 ] 

Abe White commented on OPENJPA-171:
---

It would speed things up a lot if you attached a working test case 
demonstrating the problem.

 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 AbstractAddresses. 
 An AbstractAddress can be an EMailAddressImpl or a PostalAddressImpl. All 
 these objects extend AbstractBusinessObject. 
 When I call entityManager.getReference(PersonImpl.class, 1) I get the 
 EMailAddressImpl object with id 1 instead of a PersonImpl object. 
 If I get the object with a query (select p from PersonImpl p where p.id='1') 
 everything is ok.
 My mapping file is : 
 entity-mappings xmlns=http://java.sun.com/xml/ns/persistence/orm;
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   xsi:schemaLocation=http://java.sun.com/xml/ns/persistence/orm 
 http://java.sun.com/xml/ns/persistence/orm_1_0.xsd;
   version=1.0
   mapped-superclass
   class=ch.admin.bit.fw2.bm.AbstractBusinessObjectImpl
   attributes
   id name=id
   column name=ID /
   generated-value strategy=SEQUENCE 
 generator=TimeSeq/
   sequence-generator name=TimeSeq 
 sequence-name=time()/
   /id
   version name=version /
   /attributes
   /mapped-superclass
   
   entity class=ch.admin.bit.fw2.demo.bm.address.AbstractAddressImpl
   table name=ADDRESS/table
   inheritance strategy=SINGLE_TABLE/
   discriminator-column name=DISCRIMINANT length=1/
   attributes
   basic name=addressName
   column name=ADDRESS_NAME/
   /basic
   /attributes
   /entity
   
   entity class=ch.admin.bit.fw2.demo.bm.address.EMailAddressImpl
   discriminator-valueE/discriminator-value
   attributes
   basic name=domain
   column name=EMAIL_DOMAIN/
   /basic
   basic name=name
   column name=EMAIL_NAME/
   /basic
   /attributes
   /entity
   
   entity class=ch.admin.bit.fw2.demo.bm.address.PostalAddressImpl
   discriminator-valueP/discriminator-value
   attributes
   basic name=firstName
   column name=FIRST_NAME/
   /basic
   basic name=lastName
   column name=LAST_NAME/
   /basic
   basic name=street/basic
   basic name=country/basic
   basic name=zip/basic
   basic name=city/basic
   /attributes
   /entity
   
   entity class=ch.admin.bit.fw2.demo.bm.person.PersonImpl
   table name=PERSON /
   attributes
   basic name=title /
   basic name=firstName
   column name=FIRST_NAME /
   /basic
   basic name=lastName
   column name=LAST_NAME /
   /basic
   one-to-many name=addresses
   
 target-entity=ch.admin.bit.fw2.demo.bm.address.AbstractAddressImpl
   join-table name=PERS_ADDR
   join-column name=ID_PERSON /
   inverse-join-column name=ID_ADDRESS 
 /
   /join-table
   /one-to-many
   /attributes
   /entity
   
 /entity-mappings
 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) ,
 

[jira] Commented: (OPENJPA-171) EntityManager.getReference() returns an object of a wronc class

2007-03-13 Thread Abe White (JIRA)

[ 
https://issues.apache.org/jira/browse/OPENJPA-171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480510
 ] 

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(ClassT cls, Object id) method could possibly 
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 AbstractAddresses. 
 An AbstractAddress can be an EMailAddressImpl or a PostalAddressImpl. All 
 these objects extend AbstractBusinessObject. 
 When I call entityManager.getReference(PersonImpl.class, 1) I get the 
 EMailAddressImpl object with id 1 instead of a PersonImpl object. 
 If I get the object with a query (select p from PersonImpl p where p.id='1') 
 everything is ok.
 My mapping file is : 
 entity-mappings xmlns=http://java.sun.com/xml/ns/persistence/orm;
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   xsi:schemaLocation=http://java.sun.com/xml/ns/persistence/orm 
 http://java.sun.com/xml/ns/persistence/orm_1_0.xsd;
   version=1.0
   mapped-superclass
   class=ch.admin.bit.fw2.bm.AbstractBusinessObjectImpl
   attributes
   id name=id
   column name=ID /
   generated-value strategy=SEQUENCE 
 generator=TimeSeq/
   sequence-generator name=TimeSeq 
 sequence-name=time()/
   /id
   version name=version /
   /attributes
   /mapped-superclass
   
   entity class=ch.admin.bit.fw2.demo.bm.address.AbstractAddressImpl
   table name=ADDRESS/table
   inheritance strategy=SINGLE_TABLE/
   discriminator-column name=DISCRIMINANT length=1/
   attributes
   basic name=addressName
   column name=ADDRESS_NAME/
   /basic
   /attributes
   /entity
   
   entity class=ch.admin.bit.fw2.demo.bm.address.EMailAddressImpl
   discriminator-valueE/discriminator-value
   attributes
   basic name=domain
   column name=EMAIL_DOMAIN/
   /basic
   basic name=name
   column name=EMAIL_NAME/
   /basic
   /attributes
   /entity
   
   entity class=ch.admin.bit.fw2.demo.bm.address.PostalAddressImpl
   discriminator-valueP/discriminator-value
   attributes
   basic name=firstName
   column name=FIRST_NAME/
   /basic
   basic name=lastName
   column name=LAST_NAME/
   /basic
   basic name=street/basic
   basic name=country/basic
   basic name=zip/basic
   basic name=city/basic
   /attributes
   /entity
   
   entity class=ch.admin.bit.fw2.demo.bm.person.PersonImpl
   table name=PERSON /
   attributes
   basic name=title /
   basic name=firstName
   column name=FIRST_NAME /
   /basic
   basic name=lastName
   column name=LAST_NAME /
   /basic
   one-to-many name=addresses
   
 target-entity=ch.admin.bit.fw2.demo.bm.address.AbstractAddressImpl
   join-table name=PERS_ADDR
   join-column name=ID_PERSON /
   inverse-join-column name=ID_ADDRESS 
 /
   /join-table
   /one-to-many
   /attributes
   /entity
   
 /entity-mappings
 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)