Patch for CAY-360

From: Michael Gentry (Yes, I'm a Contractor) ("Michael)
Date: Tue Sep 06 2005 - 12:12:53 EDT

  • Next message: Kevin Menard: "Re: Cayenne 1.2 + PostgreSQL"

    Could a few eyeballs look over this and give me feedback? It seems to work
    with my test case.

    In org.objectstyle.cayenne.query.SelectQuery.java:354 (at least in my 1.2
    checkout):

        public SelectQuery queryWithParameters(Map parameters, boolean
    pruneMissing) {
            // create a query replica
            SelectQuery query = new SelectQuery();
            query.setDistinct(distinct);

            this.selectProperties.copyToProperties(query.selectProperties);

            query.setLoggingLevel(logLevel);
            query.setParentObjEntityName(parentObjEntityName);
            query.setParentQualifier(parentQualifier);
            query.setRoot(root);

            // TODO: implement algorithm for building the name based on the
    original name and
            // the hashcode of the map of parameters. This way query clone can
    take advantage
            // of caching.

            Iterator keyValuePairs = parameters.entrySet().iterator();
            HashCodeBuilder parametersHash = new HashCodeBuilder();

            while (keyValuePairs.hasNext()) {
              Map.Entry entry = (Map.Entry) keyValuePairs.next();

              parametersHash.append(entry.getKey());
              parametersHash.append(entry.getValue());
            }

            query.setName(name + parametersHash.toHashCode());

            if (prefetches != null) {
                query.addPrefetches(prefetches);
            }

            if (orderings != null) {
                query.addOrderings(orderings);
            }

            if (customDbAttributes != null) {
                query.addCustomDbAttributes(customDbAttributes);
            }

            // substitute qualifier parameters
            if (qualifier != null) {
                query.setQualifier(qualifier.expWithParameters(parameters,
    pruneMissing));
            }

            return query;
        }

    I bolded the portions of interest. Of course, the TODO can be removed if
    everything thinks this is valid.

    Thanks,

    /dev/mrg

    -- 
    I'm Victor. I'm the cleaner.
    



    This archive was generated by hypermail 2.0.0 : Tue Sep 06 2005 - 12:12:57 EDT