openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fay Wang <>
Subject unpredictable ordering in push-downed sql from JPQL
Date Fri, 02 May 2008 22:46:09 GMT
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 ?1, t.age = ?2 WHERE = ?3"

      we observe two different push-down sql could be generated:
      UPDATE PDQBasicA t0 SET name = ?, age = ? WHERE ( = ?)

      UPDATE PDQBasicA t0 SET age = ?, name = ? WHERE ( = ?)

      This unpredictable behavior breaks our application. The       indeterministic ordering
of the update list is due to the indeterminsitic 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()]);


Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

View raw message