openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christiaan (JIRA)" <>
Subject [jira] [Created] (OPENJPA-2455) Wrong sequence number in ORDR column for collections
Date Mon, 18 Nov 2013 10:39:20 GMT
Christiaan created OPENJPA-2455:

             Summary: Wrong sequence number in ORDR column for collections
                 Key: OPENJPA-2455
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 2.2.2
            Reporter: Christiaan

I had the following scenario
- Add 4 objects to a List
- Delete first 3
- Evict List
- Add number 5
- Reload collection, number 5 appears before item 4

In StoreCollectionFieldStrategy.loadEagerJoin() the sequence number is not always set to the
max value of current ordr numbers, so it will be wrongly initialized with the size of the
collection. So in above scenario, number 5 gets index 1. 

This part of the code is not executed, since ref is not null:
 // extract the owner id value
            ref = getNextRef(ownerMapping, store, res, ref, refJoins);
            if (ref == null) {
                // if the old coll was an ordered tracking proxy, set
                // its seq value to the last order val we read
                if (seq != 0 && coll instanceof Proxy)
                    ((Proxy) coll).getChangeTracker().setNextSequence(seq);
                if (i != 0)

At the end of the list this is executed, so the sequence number is never set.
            if (! || res.indexOf() != typeIdx) {

Add following code at end of method (Similar to Load())

        if ((coll instanceof Proxy) && 
            ((Proxy) coll).getChangeTracker() != null && (field.getOrderColumn() !=
null)) {
            ((Proxy) coll).getChangeTracker().setNextSequence(seq);

This message was sent by Atlassian JIRA

View raw message