Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 71805 invoked from network); 2 May 2008 23:31:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 May 2008 23:31:56 -0000 Received: (qmail 95370 invoked by uid 500); 2 May 2008 23:31:57 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 95336 invoked by uid 500); 2 May 2008 23:31:57 -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 95319 invoked by uid 99); 2 May 2008 23:31:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 May 2008 16:31:57 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [216.252.110.52] (HELO web55806.mail.re3.yahoo.com) (216.252.110.52) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 02 May 2008 23:31:12 +0000 Received: (qmail 91649 invoked by uid 60001); 2 May 2008 23:31:24 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:Cc:MIME-Version:Content-Type:Message-ID; b=aypfOt7kxrurcy4FpqgjnHyX3oWoEyuNyRZwgp/nqj4qydGHbGhZbsrCILXtA6djHsBDfpRdUuIeQgi4t3XYhmkT0L9dgsu1zlH0ScHDQFJxig/t6ffARQsp9kpiNnRPwEh+OhzG3YJ6RB0HAoiXwWmWrVwz5fXkHK73xYPT7h8=; X-YMail-OSG: 9lVW0WwVM1maOkwg4m9UYk_LzY.C6yD28B06kiRJczAySCqQV.7LX5aGTtMxPT2E0pfUzvlfy9bultROJfkelT6hqXiyVG0OsXorLbeTF9JfWgZqJOTJoNp7wVzTk5E15Bw- Received: from [129.42.184.35] by web55806.mail.re3.yahoo.com via HTTP; Fri, 02 May 2008 16:31:23 PDT X-Mailer: YahooMailWebService/0.7.185 Date: Fri, 2 May 2008 16:31:23 -0700 (PDT) From: Fay Wang Reply-To: fyw300@yahoo.com Subject: Unpredictable set clause in generated sql To: dev@openjpa.apache.org Cc: Fay Wang MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <955848.90434.qm@web55806.mail.re3.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi, Our application requires the push-down sql from named/dynamic query be the same each time a same JPQL is executed. In the following JPQL example, query="UPDATE BasicA t set t.name= ?1, t.age = ?2 WHERE t.id = ?3" we observe two different push-down sql could be generated: UPDATE PDQBasicA t0 SET name = ?, age = ? WHERE (t0.id = ?) UPDATE PDQBasicA t0 SET age = ?, name = ? WHERE (t0.id = ?) This unpredictable behavior breaks our application. The indeterministic ordering of the update list is due to the indeterministic ordering provided by HashMap and HashSet in QueryExpressions and JPQLExpressionBuilder, respectively. When the HashMap is changed to LinkedHashMap and HashSet to LinkedHashSet, the access order based on insertion will be preserved and the generated push-down sql will have predictable ordering of update list. Is there an alternative way to address this issue? Should a JIRA issue be open to fix this problem? Any comment is appreciated. In QueryExpressions: /** * Add an update. */ public void putUpdate(Path path, Value val) { if (updates == Collections.EMPTY_MAP) updates = new HashMap(); <== change HashMap to LinkedHashMap updates.put(path, val); } In JPQLExpressionBuilder: JPQLNode[] findChildrenByID(int id) { Collection set = new HashSet(); <== change HashSet to LinkedHashSet findChildrenByID(id, set); return (JPQLNode[]) set.toArray(new JPQLNode[set.size()]); } -Fay ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ