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:
      
      (1) UPDATE PDQBasicA t0 SET name = ?, age = ? WHERE (t0.id = ?)

      (2) 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()]);
    }


Regards,
Fay


      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

Reply via email to