You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Yanko Zhivkov (JIRA)" <ji...@apache.org> on 2009/02/26 19:59:01 UTC

[jira] Created: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation
--------------------------------------------------------------------------------------------------------

                 Key: OPENJPA-944
                 URL: https://issues.apache.org/jira/browse/OPENJPA-944
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc, kernel
    Affects Versions: 1.2.0, 1.1.0, 1.0.3, 1.0.2, 1.0.1, 1.0.0
         Environment: JDK: Sun 1.5
Database: Derby 10.2.2.0
OS: Windows XP 
            Reporter: Yanko Zhivkov
            Priority: Critical


A problem with loading recursively referenced entities was found when there is a complex relation of the following kind:
Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
where Branch has a self reference to itself.

Using a FetchPlan with a fetch group that has a fetch attribute with recursionDepth=-1 does not produce the expected result and only the first of the Branch nodes is loaded. 
Loading a Leaf with 5 branches in a row and traversing through them fails right on level 3 (starting from 5 downwards) which leads to the thought that OpenJPA loads only the first element (along with its direct parent).


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


Re: [jira] Created: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
  Which version of OpenJPA is being used?
   With a related issue it was found that OpenJPA 1.2.x QuerySQLCache could
be the reason. So either 
   a) deactivate QuerySQLCache with 1.2.x 
or b) use trunk version that has a completely reworked version  of
QuerySQLCache 


JIRA jira@apache.org wrote:
> 
> FetchAttribute.recursionDepth = -1 does not load properly self referenced
> entities in a complex relation
> --------------------------------------------------------------------------------------------------------
> 
>                  Key: OPENJPA-944
>                  URL: https://issues.apache.org/jira/browse/OPENJPA-944
>              Project: OpenJPA
>           Issue Type: Bug
>           Components: jdbc, kernel
>     Affects Versions: 1.2.0, 1.1.0, 1.0.3, 1.0.2, 1.0.1, 1.0.0
>          Environment: JDK: Sun 1.5
> Database: Derby 10.2.2.0
> OS: Windows XP 
>             Reporter: Yanko Zhivkov
>             Priority: Critical
> 
> 
> A problem with loading recursively referenced entities was found when
> there is a complex relation of the following kind:
> Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
> where Branch has a self reference to itself.
> 
> Using a FetchPlan with a fetch group that has a fetch attribute with
> recursionDepth=-1 does not produce the expected result and only the first
> of the Branch nodes is loaded. 
> Loading a Leaf with 5 branches in a row and traversing through them fails
> right on level 3 (starting from 5 downwards) which leads to the thought
> that OpenJPA loads only the first element (along with its direct parent).
> 
> 
> -- 
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/-jira--Created%3A-%28OPENJPA-944%29-FetchAttribute.recursionDepth-%3D--1-does-not-load-properly-self-referenced-entities-in-a-complex-relation-tp2391526p2392031.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


[jira] Updated: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

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

Yanko Zhivkov updated OPENJPA-944:
----------------------------------

    Attachment: openjpa_complex_relation_recursion_test.zip

Attached a test case that shows the error. I tried the test case with 1.0.0, 1.0.1, 1.0.3, 1.1.0 and 1.2.0 and even with the latest trunk code but neither of them work.




> FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-944
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-944
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.2.0
>         Environment: JDK: Sun 1.5
> Database: Derby 10.2.2.0
> OS: Windows XP 
>            Reporter: Yanko Zhivkov
>            Priority: Critical
>         Attachments: openjpa_complex_relation_recursion_test.zip
>
>
> A problem with loading recursively referenced entities was found when there is a complex relation of the following kind:
> Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
> where Branch has a self reference to itself.
> Using a FetchPlan with a fetch group that has a fetch attribute with recursionDepth=-1 does not produce the expected result and only the first of the Branch nodes is loaded. 
> Loading a Leaf with 5 branches in a row and traversing through them fails right on level 3 (starting from 5 downwards) which leads to the thought that OpenJPA loads only the first element (along with its direct parent).

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


[jira] Updated: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

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

Donald Woods updated OPENJPA-944:
---------------------------------

    Fix Version/s:     (was: 2.0.0)
                   2.0.0-beta

> FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-944
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-944
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.2.0
>         Environment: JDK: Sun 1.5
> Database: Derby 10.2.2.0
> OS: Windows XP 
>            Reporter: Yanko Zhivkov
>            Assignee: Pinaki Poddar
>            Priority: Critical
>             Fix For: 2.0.0-beta
>
>         Attachments: fix_recursive_entity_loading-OPENJPA-944-openjpa1.0.1.patch, fix_recursive_entity_loading-OPENJPA-944-openjpa1.2.1.patch, openjpa_complex_relation_recursion_test.zip
>
>
> A problem with loading recursively referenced entities was found when there is a complex relation of the following kind:
> Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
> where Branch has a self reference to itself.
> Using a FetchPlan with a fetch group that has a fetch attribute with recursionDepth=-1 does not produce the expected result and only the first of the Branch nodes is loaded. 
> Loading a Leaf with 5 branches in a row and traversing through them fails right on level 3 (starting from 5 downwards) which leads to the thought that OpenJPA loads only the first element (along with its direct parent).

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


[jira] Issue Comment Edited: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

Posted by "Yanko Zhivkov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12677102#action_12677102 ] 

yzhivkov edited comment on OPENJPA-944 at 2/26/09 11:16 AM:
-----------------------------------------------------------------

Attached a test case that shows the error. I tried the test case with 1.0.0, 1.0.1, 1.0.3, 1.1.0 and 1.2.0 and even with the latest trunk code but neither of them work.

The provided test case extends SingleEMFTestCase and can directly be copied into openjpa-persistence-jdbc/src/test for being executed within there as well.


      was (Author: yzhivkov):
    Attached a test case that shows the error. I tried the test case with 1.0.0, 1.0.1, 1.0.3, 1.1.0 and 1.2.0 and even with the latest trunk code but neither of them work.



  
> FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-944
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-944
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.2.0
>         Environment: JDK: Sun 1.5
> Database: Derby 10.2.2.0
> OS: Windows XP 
>            Reporter: Yanko Zhivkov
>            Priority: Critical
>         Attachments: openjpa_complex_relation_recursion_test.zip
>
>
> A problem with loading recursively referenced entities was found when there is a complex relation of the following kind:
> Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
> where Branch has a self reference to itself.
> Using a FetchPlan with a fetch group that has a fetch attribute with recursionDepth=-1 does not produce the expected result and only the first of the Branch nodes is loaded. 
> Loading a Leaf with 5 branches in a row and traversing through them fails right on level 3 (starting from 5 downwards) which leads to the thought that OpenJPA loads only the first element (along with its direct parent).

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


[jira] Issue Comment Edited: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

Posted by "Yanko Zhivkov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12677102#action_12677102 ] 

yzhivkov edited comment on OPENJPA-944 at 2/26/09 2:21 PM:
----------------------------------------------------------------

Attached a test case that shows the error. I tried the test case with 1.0.0, 1.0.1, 1.0.3, 1.1.0 and 1.2.0 and even with the latest trunk code but neither of them work.

For running the test case unzip the zip file and execute from a shell:
  mvn install

The provided test case extends SingleEMFTestCase and can directly be copied into openjpa-persistence-jdbc/src/test for being executed within there as well.


      was (Author: yzhivkov):
    Attached a test case that shows the error. I tried the test case with 1.0.0, 1.0.1, 1.0.3, 1.1.0 and 1.2.0 and even with the latest trunk code but neither of them work.

The provided test case extends SingleEMFTestCase and can directly be copied into openjpa-persistence-jdbc/src/test for being executed within there as well.

  
> FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-944
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-944
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.2.0
>         Environment: JDK: Sun 1.5
> Database: Derby 10.2.2.0
> OS: Windows XP 
>            Reporter: Yanko Zhivkov
>            Priority: Critical
>         Attachments: openjpa_complex_relation_recursion_test.zip
>
>
> A problem with loading recursively referenced entities was found when there is a complex relation of the following kind:
> Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
> where Branch has a self reference to itself.
> Using a FetchPlan with a fetch group that has a fetch attribute with recursionDepth=-1 does not produce the expected result and only the first of the Branch nodes is loaded. 
> Loading a Leaf with 5 branches in a row and traversing through them fails right on level 3 (starting from 5 downwards) which leads to the thought that OpenJPA loads only the first element (along with its direct parent).

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


[jira] Assigned: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

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

Pinaki Poddar reassigned OPENJPA-944:
-------------------------------------

    Assignee: Pinaki Poddar

> FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-944
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-944
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.2.0
>         Environment: JDK: Sun 1.5
> Database: Derby 10.2.2.0
> OS: Windows XP 
>            Reporter: Yanko Zhivkov
>            Assignee: Pinaki Poddar
>            Priority: Critical
>             Fix For: 2.0.0
>
>         Attachments: fix_recursive_entity_loading-OPENJPA-944-openjpa1.0.1.patch, fix_recursive_entity_loading-OPENJPA-944-openjpa1.2.1.patch, openjpa_complex_relation_recursion_test.zip
>
>
> A problem with loading recursively referenced entities was found when there is a complex relation of the following kind:
> Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
> where Branch has a self reference to itself.
> Using a FetchPlan with a fetch group that has a fetch attribute with recursionDepth=-1 does not produce the expected result and only the first of the Branch nodes is loaded. 
> Loading a Leaf with 5 branches in a row and traversing through them fails right on level 3 (starting from 5 downwards) which leads to the thought that OpenJPA loads only the first element (along with its direct parent).

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


[jira] Resolved: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

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

Pinaki Poddar resolved OPENJPA-944.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0

> FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-944
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-944
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.2.0
>         Environment: JDK: Sun 1.5
> Database: Derby 10.2.2.0
> OS: Windows XP 
>            Reporter: Yanko Zhivkov
>            Assignee: Pinaki Poddar
>            Priority: Critical
>             Fix For: 2.0.0
>
>         Attachments: fix_recursive_entity_loading-OPENJPA-944-openjpa1.0.1.patch, fix_recursive_entity_loading-OPENJPA-944-openjpa1.2.1.patch, openjpa_complex_relation_recursion_test.zip
>
>
> A problem with loading recursively referenced entities was found when there is a complex relation of the following kind:
> Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
> where Branch has a self reference to itself.
> Using a FetchPlan with a fetch group that has a fetch attribute with recursionDepth=-1 does not produce the expected result and only the first of the Branch nodes is loaded. 
> Loading a Leaf with 5 branches in a row and traversing through them fails right on level 3 (starting from 5 downwards) which leads to the thought that OpenJPA loads only the first element (along with its direct parent).

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


[jira] Updated: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

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

Donald Woods updated OPENJPA-944:
---------------------------------

    Patch Info: [Patch Available]

> FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-944
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-944
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.2.0
>         Environment: JDK: Sun 1.5
> Database: Derby 10.2.2.0
> OS: Windows XP 
>            Reporter: Yanko Zhivkov
>            Priority: Critical
>         Attachments: fix_recursive_entity_loading-OPENJPA-944-openjpa1.0.1.patch, fix_recursive_entity_loading-OPENJPA-944-openjpa1.2.1.patch, openjpa_complex_relation_recursion_test.zip
>
>
> A problem with loading recursively referenced entities was found when there is a complex relation of the following kind:
> Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
> where Branch has a self reference to itself.
> Using a FetchPlan with a fetch group that has a fetch attribute with recursionDepth=-1 does not produce the expected result and only the first of the Branch nodes is loaded. 
> Loading a Leaf with 5 branches in a row and traversing through them fails right on level 3 (starting from 5 downwards) which leads to the thought that OpenJPA loads only the first element (along with its direct parent).

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


[jira] Updated: (OPENJPA-944) FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation

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

Yanko Zhivkov updated OPENJPA-944:
----------------------------------

    Attachment: fix_recursive_entity_loading-OPENJPA-944-openjpa1.2.1.patch
                fix_recursive_entity_loading-OPENJPA-944-openjpa1.0.1.patch

Attached patch files for fixing that issue for OpenJPA versions 1.0.1 and 1.2.1. The same changes could be used for the other versions as well.

I think the problem is that the recursion depth is not calculated properly. When the FetchConfiguration is created for every field-to-field relation only the type of the FieldMetaData is taken into consideration. This causes a confusion of what the real recursion depth is. 
For example if the field BranchConnection.branch refers to Branch and Branch.parent has a reference to Branch then there is the following field metadata:

|| Field || From Type || Recursion Depth ||
| branch | Branch | 1 |
| parent | Branch | -1 |

When the mappings are built and OpenJPA gets to BranchConnection.branch - > Branch.parent and tries to add the new field Branch.parent it will try to find an already existing limit and will compare the From Type of the new field to the From Type of the existing mappings (parents of the new mapping).
As the second mapping in the table has not been created yet it will grab the first one which is not what we expect and will set recursion depth 1. This prevents from getting the real recursion depth and only the first parent of the Branch connected to BranchConnection will be loaded.

For fixing this behavior a new check for the field name was added. This makes sure that when the recursion depth is being determined only the mappings that are of the same kind (fromField and fromType) will be taken into consideration.



> FetchAttribute.recursionDepth = -1 does not load properly self referenced entities in a complex relation
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-944
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-944
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc, kernel
>    Affects Versions: 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.2.0
>         Environment: JDK: Sun 1.5
> Database: Derby 10.2.2.0
> OS: Windows XP 
>            Reporter: Yanko Zhivkov
>            Priority: Critical
>         Attachments: fix_recursive_entity_loading-OPENJPA-944-openjpa1.0.1.patch, fix_recursive_entity_loading-OPENJPA-944-openjpa1.2.1.patch, openjpa_complex_relation_recursion_test.zip
>
>
> A problem with loading recursively referenced entities was found when there is a complex relation of the following kind:
> Leaf <-> BranchConnection <-> Branch(1) <- Branch(2) <- ...
> where Branch has a self reference to itself.
> Using a FetchPlan with a fetch group that has a fetch attribute with recursionDepth=-1 does not produce the expected result and only the first of the Branch nodes is loaded. 
> Loading a Leaf with 5 branches in a row and traversing through them fails right on level 3 (starting from 5 downwards) which leads to the thought that OpenJPA loads only the first element (along with its direct parent).

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