You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Christiaan (JIRA)" <ji...@apache.org> on 2008/01/25 17:01:37 UTC

[jira] Created: (OPENJPA-504) Duplicate order numbers in relationshiptable for the same List field

Duplicate order numbers in relationshiptable for the same List field
--------------------------------------------------------------------

                 Key: OPENJPA-504
                 URL: https://issues.apache.org/jira/browse/OPENJPA-504
             Project: OpenJPA
          Issue Type: Bug
         Environment: Kodo 4.1.4
            Reporter: Christiaan


I now and then encounter entries in the relationship tables for List fields (id, element, ordr) non-unique entries for id, ordr. (Two elements are placed on the same index in the same list). I am not sure how to reproduce this, but I do have a question regarding the code in StoreCollectionFieldStrategy.load(): 

ChangeTracker ct = null;
        if (field.getTypeCode() == JavaTypes.ARRAY)
            coll = new ArrayList();
        else {
            coll = sm.newProxy(field.getIndex());
            if (coll instanceof Proxy)
                ct = ((Proxy) coll).getChangeTracker();
        }

        // load values
        Result res = union.execute(store, fetch);
        try {
            int seq = 0;
            while (res.next()) {
                if (ct != null && field.getOrderColumn() != null)
                    seq = res.getInt(field.getOrderColumn());
                add(store, coll, loadElement(sm, store, fetch, res,
                    resJoins[res.indexOf()]));
            }
            if (ct != null && field.getOrderColumn() != null)
                ct.setNextSequence(seq + 1);
        } finally {
            res.close();
        }

If I am not mistaken, this initializes the changetracker for list fields for persistent objects loaded from the database with an empty list attribute (res.next() = false) with order number of "1", whereas objects with non-empty List fields which are persisted start with an order number of "0". Could this be the reason that I now and then encounter duplicate entries in the relationship table with ordernr "1"?

kind regards,
Christiaan

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


[jira] Updated: (OPENJPA-504) Duplicate order numbers in relationshiptable for the same List field

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

Christiaan updated OPENJPA-504:
-------------------------------

    Description: 
I now and then encounter entries in the relationship tables for List fields (id, element, ordr) non-unique entries for id, ordr. (Two elements are placed on the same index in the same list). I am not sure how to reproduce this, but I do have a question regarding the code in StoreCollectionFieldStrategy.load(): 

ChangeTracker ct = null;
        if (field.getTypeCode() == JavaTypes.ARRAY)
            coll = new ArrayList();
        else {
            coll = sm.newProxy(field.getIndex());
            if (coll instanceof Proxy)
                ct = ((Proxy) coll).getChangeTracker();
        }

        // load values
        Result res = union.execute(store, fetch);
        try {
            int seq = 0;
            while (res.next()) {
                if (ct != null && field.getOrderColumn() != null)
                    seq = res.getInt(field.getOrderColumn());
                add(store, coll, loadElement(sm, store, fetch, res,
                    resJoins[res.indexOf()]));
            }
            if (ct != null && field.getOrderColumn() != null)
                ct.setNextSequence(seq + 1);
        } finally {
            res.close();
        }

If I am not mistaken, this initializes the changetracker for list fields for persistent objects loaded from the database with an empty list attribute (res.next() = false) with order number of "1", whereas objects with non-empty List fields which are persisted start with an order number of "0". Could this be the reason that I now and then encounter duplicate entries in the relationship table with ordernr "1"? Actually this is also the reason why encounter duplicates for other numbers, since order number is zero based (next sequence number is initialized to size()), but as described, some lists start counting from "1".

kind regards,
Christiaan

  was:
I now and then encounter entries in the relationship tables for List fields (id, element, ordr) non-unique entries for id, ordr. (Two elements are placed on the same index in the same list). I am not sure how to reproduce this, but I do have a question regarding the code in StoreCollectionFieldStrategy.load(): 

ChangeTracker ct = null;
        if (field.getTypeCode() == JavaTypes.ARRAY)
            coll = new ArrayList();
        else {
            coll = sm.newProxy(field.getIndex());
            if (coll instanceof Proxy)
                ct = ((Proxy) coll).getChangeTracker();
        }

        // load values
        Result res = union.execute(store, fetch);
        try {
            int seq = 0;
            while (res.next()) {
                if (ct != null && field.getOrderColumn() != null)
                    seq = res.getInt(field.getOrderColumn());
                add(store, coll, loadElement(sm, store, fetch, res,
                    resJoins[res.indexOf()]));
            }
            if (ct != null && field.getOrderColumn() != null)
                ct.setNextSequence(seq + 1);
        } finally {
            res.close();
        }

If I am not mistaken, this initializes the changetracker for list fields for persistent objects loaded from the database with an empty list attribute (res.next() = false) with order number of "1", whereas objects with non-empty List fields which are persisted start with an order number of "0". Could this be the reason that I now and then encounter duplicate entries in the relationship table with ordernr "1"?

kind regards,
Christiaan


> Duplicate order numbers in relationshiptable for the same List field
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-504
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-504
>             Project: OpenJPA
>          Issue Type: Bug
>         Environment: Kodo 4.1.4
>            Reporter: Christiaan
>
> I now and then encounter entries in the relationship tables for List fields (id, element, ordr) non-unique entries for id, ordr. (Two elements are placed on the same index in the same list). I am not sure how to reproduce this, but I do have a question regarding the code in StoreCollectionFieldStrategy.load(): 
> ChangeTracker ct = null;
>         if (field.getTypeCode() == JavaTypes.ARRAY)
>             coll = new ArrayList();
>         else {
>             coll = sm.newProxy(field.getIndex());
>             if (coll instanceof Proxy)
>                 ct = ((Proxy) coll).getChangeTracker();
>         }
>         // load values
>         Result res = union.execute(store, fetch);
>         try {
>             int seq = 0;
>             while (res.next()) {
>                 if (ct != null && field.getOrderColumn() != null)
>                     seq = res.getInt(field.getOrderColumn());
>                 add(store, coll, loadElement(sm, store, fetch, res,
>                     resJoins[res.indexOf()]));
>             }
>             if (ct != null && field.getOrderColumn() != null)
>                 ct.setNextSequence(seq + 1);
>         } finally {
>             res.close();
>         }
> If I am not mistaken, this initializes the changetracker for list fields for persistent objects loaded from the database with an empty list attribute (res.next() = false) with order number of "1", whereas objects with non-empty List fields which are persisted start with an order number of "0". Could this be the reason that I now and then encounter duplicate entries in the relationship table with ordernr "1"? Actually this is also the reason why encounter duplicates for other numbers, since order number is zero based (next sequence number is initialized to size()), but as described, some lists start counting from "1".
> kind regards,
> Christiaan

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


[jira] Commented: (OPENJPA-504) Duplicate order numbers in relationshiptable for the same List field

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

Christiaan commented on OPENJPA-504:
------------------------------------

The cause of the problem appears to be in different loading mechanisms. If the first time a collection is loaded using EAGER_NONE the sequence number is initialized to 1 instead of zero (see previous comment). When this is written to the datastore and loaded again the next time with EAGER_JOIN (resulting in StoreCollectionFieldStrategy.loadEagerJoin() which invokes CollectionChangeTrackerImpl.initialSequence()) the next sequence number will be initialized to the size of the collection => 1. So both element on index zero and one get the ordr value "1"

> Duplicate order numbers in relationshiptable for the same List field
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-504
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-504
>             Project: OpenJPA
>          Issue Type: Bug
>         Environment: Kodo 4.1.4
>            Reporter: Christiaan
>
> I now and then encounter entries in the relationship tables for List fields (id, element, ordr) non-unique entries for id, ordr. (Two elements are placed on the same index in the same list). I am not sure how to reproduce this, but I do have a question regarding the code in StoreCollectionFieldStrategy.load(): 
> ChangeTracker ct = null;
>         if (field.getTypeCode() == JavaTypes.ARRAY)
>             coll = new ArrayList();
>         else {
>             coll = sm.newProxy(field.getIndex());
>             if (coll instanceof Proxy)
>                 ct = ((Proxy) coll).getChangeTracker();
>         }
>         // load values
>         Result res = union.execute(store, fetch);
>         try {
>             int seq = 0;
>             while (res.next()) {
>                 if (ct != null && field.getOrderColumn() != null)
>                     seq = res.getInt(field.getOrderColumn());
>                 add(store, coll, loadElement(sm, store, fetch, res,
>                     resJoins[res.indexOf()]));
>             }
>             if (ct != null && field.getOrderColumn() != null)
>                 ct.setNextSequence(seq + 1);
>         } finally {
>             res.close();
>         }
> If I am not mistaken, this initializes the changetracker for list fields for persistent objects loaded from the database with an empty list attribute (res.next() = false) with order number of "1", whereas objects with non-empty List fields which are persisted start with an order number of "0". Could this be the reason that I now and then encounter duplicate entries in the relationship table with ordernr "1"? Actually this is also the reason why encounter duplicates for other numbers, since order number is zero based (next sequence number is initialized to size()), but as described, some lists start counting from "1".
> kind regards,
> Christiaan

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


[jira] Resolved: (OPENJPA-504) Duplicate order numbers in relationshiptable for the same List field

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

Christiaan resolved OPENJPA-504.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 1.2.0
                   1.1.0

Fixed due to issue OPENJPA-567

> Duplicate order numbers in relationshiptable for the same List field
> --------------------------------------------------------------------
>
>                 Key: OPENJPA-504
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-504
>             Project: OpenJPA
>          Issue Type: Bug
>         Environment: Kodo 4.1.4
>            Reporter: Christiaan
>             Fix For: 1.1.0, 1.2.0
>
>
> I now and then encounter entries in the relationship tables for List fields (id, element, ordr) non-unique entries for id, ordr. (Two elements are placed on the same index in the same list). I am not sure how to reproduce this, but I do have a question regarding the code in StoreCollectionFieldStrategy.load(): 
> ChangeTracker ct = null;
>         if (field.getTypeCode() == JavaTypes.ARRAY)
>             coll = new ArrayList();
>         else {
>             coll = sm.newProxy(field.getIndex());
>             if (coll instanceof Proxy)
>                 ct = ((Proxy) coll).getChangeTracker();
>         }
>         // load values
>         Result res = union.execute(store, fetch);
>         try {
>             int seq = 0;
>             while (res.next()) {
>                 if (ct != null && field.getOrderColumn() != null)
>                     seq = res.getInt(field.getOrderColumn());
>                 add(store, coll, loadElement(sm, store, fetch, res,
>                     resJoins[res.indexOf()]));
>             }
>             if (ct != null && field.getOrderColumn() != null)
>                 ct.setNextSequence(seq + 1);
>         } finally {
>             res.close();
>         }
> If I am not mistaken, this initializes the changetracker for list fields for persistent objects loaded from the database with an empty list attribute (res.next() = false) with order number of "1", whereas objects with non-empty List fields which are persisted start with an order number of "0". Could this be the reason that I now and then encounter duplicate entries in the relationship table with ordernr "1"? Actually this is also the reason why encounter duplicates for other numbers, since order number is zero based (next sequence number is initialized to size()), but as described, some lists start counting from "1".
> kind regards,
> Christiaan

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