You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Przemek Koprowski (JIRA)" <ji...@apache.org> on 2008/08/06 18:14:44 UTC

[jira] Created: (OPENJPA-677) Single Table Inheritance Strategy causes entity identity issues

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


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.


[jira] Commented: (OPENJPA-677) Single Table Inheritance Strategy causes entity identity issues

Posted by "Pinaki Poddar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620874#action_12620874 ] 

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

This is an intermediate (and inaccurate) fix for the problem.
This will only work when the most-derived class is target of a relation.
For example, declared type of RegularUser.admin is Admin which is the most-derived class in this case and hence only the fix works. Otherwise, most likely it will show the same error.

Will attempt to put a more comprehensive fix 

> 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.


[jira] Assigned: (OPENJPA-677) Single Table Inheritance Strategy causes entity identity issues

Posted by "Pinaki Poddar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pinaki Poddar reassigned OPENJPA-677:
-------------------------------------

    Assignee: Pinaki Poddar

> 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.


[jira] Updated: (OPENJPA-677) Single Table Inheritance Strategy causes entity identity issues

Posted by "Donald Woods (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Donald Woods updated OPENJPA-677:
---------------------------------

    Fix Version/s: 2.0.0-M1

> 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
>             Fix For: 2.0.0-M1
>
>         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.


[jira] Resolved: (OPENJPA-677) Single Table Inheritance Strategy causes entity identity issues

Posted by "Przemek Koprowski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Przemek Koprowski resolved OPENJPA-677.
---------------------------------------

    Resolution: Fixed

Thank you.

> 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.


[jira] Updated: (OPENJPA-677) Single Table Inheritance Strategy causes entity identity issues

Posted by "Przemek Koprowski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-677?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Przemek Koprowski updated OPENJPA-677:
--------------------------------------

    Attachment: TestJPAIdentityWhenSingleTable.zip

In order to run tests:
1. Add OpenJPA libraries to the build path.
2. Change the path in the build.properties file.
3. Run the enchanceWorkspaceAndDeleteDB task from build.xml.

> 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
>         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.


[jira] Commented: (OPENJPA-677) Single Table Inheritance Strategy causes entity identity issues

Posted by "Pinaki Poddar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-677?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620879#action_12620879 ] 

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

The later fix is more general. Please confirm if this fix resolves the reported issue or not.


> 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.


[jira] Commented: (OPENJPA-677) Single Table Inheritance Strategy causes entity identity issues

Posted by "Pinaki Poddar (JIRA)" <ji...@apache.org>.
    [ 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.