Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3E270107E0 for ; Mon, 18 Nov 2013 10:39:30 +0000 (UTC) Received: (qmail 80440 invoked by uid 500); 18 Nov 2013 10:39:29 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 80281 invoked by uid 500); 18 Nov 2013 10:39:24 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 80263 invoked by uid 99); 18 Nov 2013 10:39:21 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Nov 2013 10:39:21 +0000 Date: Mon, 18 Nov 2013 10:39:20 +0000 (UTC) From: "Christiaan (JIRA)" To: dev@openjpa.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (OPENJPA-2455) Wrong sequence number in ORDR column for collections MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Christiaan created OPENJPA-2455: ----------------------------------- Summary: Wrong sequence number in ORDR column for collections Key: OPENJPA-2455 URL: https://issues.apache.org/jira/browse/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 Cause: 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) res.pushBack(); break; } At the end of the list this is executed, so the sequence number is never set. if (!res.next() || res.indexOf() != typeIdx) { res.pushBack(); break; } Solution: 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 (v6.1#6144)