You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Xiaoqin Feng (JIRA)" <ji...@apache.org> on 2008/02/21 21:31:19 UTC

[jira] Created: (OPENJPA-521) Collection ordering doesn''t work if the cache is enabled

Collection ordering doesn''t work if the cache is enabled
---------------------------------------------------------

                 Key: OPENJPA-521
                 URL: https://issues.apache.org/jira/browse/OPENJPA-521
             Project: OpenJPA
          Issue Type: Bug
          Components: datacache
    Affects Versions: 1.0.2, 1.0.1, 1.0.0, 0.9.7
         Environment: Kodo4.1.4 with OpenJPA1.0.0
            Reporter: Xiaoqin Feng


In a use case that has 2 persistence classes - parent and child.  Parent and child is one-many relationship. 
Parent entity has a collection of children.

When order-by is set for collection of children and data cache is enabled, inserting children, updating children's field value that is used by ordering will cause collection out of order. But data cache doesn't aware this and returned out of order collection.

If data cache is disabled, it always use SQL query with "ORDER BY" applied so collection is returned in correct order.

Test case will be attached.

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


[jira] Commented: (OPENJPA-521) Collection ordering doesn''t work if the cache is enabled

Posted by "Xiaoqin Feng (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-521?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12571238#action_12571238 ] 

Xiaoqin Feng commented on OPENJPA-521:
--------------------------------------

Fix is added. Please check attached patch.

Here is a summary of the fix:
1. In case a new collection field is persisted, it will not put this field into data cache. Users may not insert child in order so the collection could be out of order. 
2. In case that this collection field is updated (add/remove child from collection), this field is invalidated in data cache. 
3. If a child table column is used by "order by" setting, update this child column may result in collection field out of order.      DataCachePCDataImpl.clearInverseRelationCache()  is added to handle this case. 
4.Cache will be updated if it is not the 3 above.  For example, result from select. 
For invalidation, only field data in data cache is invalidated. Other fields in the object are not invalidated.

Only org.apache.openjpa.datacache.DataCachePCDataImpl is changed for the fix.



> Collection ordering doesn''t work if the cache is enabled
> ---------------------------------------------------------
>
>                 Key: OPENJPA-521
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-521
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: datacache
>    Affects Versions: 0.9.7, 1.0.0, 1.0.1, 1.0.2
>         Environment: Kodo4.1.4 with OpenJPA1.0.0
>            Reporter: Xiaoqin Feng
>         Attachments: openjpa-521.patch, testcase.zip
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> In a use case that has 2 persistence classes - parent and child.  Parent and child is one-many relationship. 
> Parent entity has a collection of children.
> When order-by is set for collection of children and data cache is enabled, inserting children, updating children's field value that is used by ordering will cause collection out of order. But data cache doesn't aware this and returned out of order collection.
> If data cache is disabled, it always use SQL query with "ORDER BY" applied so collection is returned in correct order.
> Test case will be attached.

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


[jira] Commented: (OPENJPA-521) Collection ordering doesn''t work if the cache is enabled

Posted by "Xiaoqin Feng (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-521?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572728#action_12572728 ] 

Xiaoqin Feng commented on OPENJPA-521:
--------------------------------------

openjpatestcase.zip contains the test suite that could be added to current openjpa tests.

> Collection ordering doesn''t work if the cache is enabled
> ---------------------------------------------------------
>
>                 Key: OPENJPA-521
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-521
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: datacache
>    Affects Versions: 0.9.7, 1.0.0, 1.0.1, 1.0.2
>         Environment: Kodo4.1.4 with OpenJPA1.0.0
>            Reporter: Xiaoqin Feng
>         Attachments: openjpa-521-v2.patch, openjpa-521.patch, openjpatestcase.zip, testcase.zip
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> In a use case that has 2 persistence classes - parent and child.  Parent and child is one-many relationship. 
> Parent entity has a collection of children.
> When order-by is set for collection of children and data cache is enabled, inserting children, updating children's field value that is used by ordering will cause collection out of order. But data cache doesn't aware this and returned out of order collection.
> If data cache is disabled, it always use SQL query with "ORDER BY" applied so collection is returned in correct order.
> Test case will be attached.

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


[jira] Updated: (OPENJPA-521) Collection ordering doesn''t work if the cache is enabled

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

Xiaoqin Feng updated OPENJPA-521:
---------------------------------

    Remaining Estimate: 168h  (was: 0.12h)
     Original Estimate: 168h  (was: 0.12h)

> Collection ordering doesn''t work if the cache is enabled
> ---------------------------------------------------------
>
>                 Key: OPENJPA-521
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-521
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: datacache
>    Affects Versions: 0.9.7, 1.0.0, 1.0.1, 1.0.2
>         Environment: Kodo4.1.4 with OpenJPA1.0.0
>            Reporter: Xiaoqin Feng
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> In a use case that has 2 persistence classes - parent and child.  Parent and child is one-many relationship. 
> Parent entity has a collection of children.
> When order-by is set for collection of children and data cache is enabled, inserting children, updating children's field value that is used by ordering will cause collection out of order. But data cache doesn't aware this and returned out of order collection.
> If data cache is disabled, it always use SQL query with "ORDER BY" applied so collection is returned in correct order.
> Test case will be attached.

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