openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fay Wang <>
Subject push-down SQL for named/dynamic query has unpredictable ordering
Date Fri, 02 May 2008 21:00:34 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:
      (1) UPDATE PDQBasicA t0 SET name = ?, age = ? WHERE ( = ?)

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

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


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

View raw message