openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-677) Single Table Inheritance Strategy causes entity identity issues
Date Fri, 08 Aug 2008 06:46:46 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620858#action_12620858
] 

Pinaki Poddar commented on OPENJPA-677:
---------------------------------------

The bug is reproducible.

The workaround is to change RegularUsr.admin field from lazily loaded to eagerly loaded.

The bug seems to be how OpenJPA determines the concrete type of a relation from the record
row data and the discrimnator column. In this case
mysql> select * from computeruser;
---------------------------------------
| oid   DTYPE    ADMIN_OID 
---------------------------------------
 101     admin       NULL 
 102     user           101 
---------------------------------------

During load of row 102, i.e. '102 'user' 101', OpenJPA tries to store a FK (pointing to Admin)
for the row 102 (which represents a RegularUser).
However, because the row's discrimnator value is 'user', OpenJPA wrongly assumes that 101
is identifier for RegularUser and that is the oid is store intermediately in RegularUser-102's
admin field.

Later when OpenJPA reads the full row 101, (say for find()) it does construct a Admin-102
instance but that other identifier has created a different Admin object  and hence the error.

Eager loading gets rid of the problem because then both the rows are read in a single query
and the ambiguity of discriminator value  does not arise.

> Single Table Inheritance Strategy causes entity identity issues
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-677
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-677
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.1.0, 1.1.1, 1.2.0, 1.2.1, 1.3.0
>         Environment: IBM Java 1.5
>            Reporter: Przemek Koprowski
>            Assignee: Pinaki Poddar
>         Attachments: TestJPAIdentityWhenSingleTable.zip
>
>
> Entity objects that are pulled out from the database using bean methods (get*()) are
not the same objects that are pulled out using using other methods(find(), getReference()).

> This occurs only when using Single Table Inheritance.
> This works on 0.9.7, in other versions Exception is thrown (https://issues.apache.org/jira/browse/OPENJPA-494)
, in latest version from trunk test fails.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message