[Mulgara-svn] r425 - in trunk/src/jar: query/java/org/mulgara/query resolver/java/org/mulgara/resolver

andrae at mulgara.org andrae at mulgara.org
Tue Sep 11 12:33:32 UTC 2007


Author: andrae
Date: 2007-09-11 07:33:31 -0500 (Tue, 11 Sep 2007)
New Revision: 425

Added:
   trunk/src/jar/resolver/java/org/mulgara/resolver/MutableLocalQueryImpl.java
Removed:
   trunk/src/jar/query/java/org/mulgara/query/Transformable.java
Modified:
   trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java
   trunk/src/jar/query/java/org/mulgara/query/ModelIntersection.java
   trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java
   trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java
   trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java
   trunk/src/jar/query/java/org/mulgara/query/ModelResource.java
   trunk/src/jar/query/java/org/mulgara/query/ModelUnion.java
   trunk/src/jar/query/java/org/mulgara/query/Query.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/Database.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQuery.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/SubqueryAnswer.java
Log:
svn merge -r408:COMMITTED ../branches/mgr-69/

Refactor to eliminate LocalQuery and provide a single path for simple constraint
resolution.



Modified: trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelExpression.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -27,9 +27,9 @@
 
 package org.mulgara.query;
 
-// used only in doc comments
 import java.net.*;
 import java.util.*;
+import java.io.Serializable;
 
 /**
  * An expression whose leaves are the {@link URL}s of RDF models.
@@ -49,7 +49,7 @@
  *
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
-public interface ModelExpression extends Transformable, Cloneable {
+public interface ModelExpression extends Cloneable, Serializable {
 
   /**
    * Allow newer compiled version of the stub to operate when changes
@@ -70,27 +70,6 @@
   public Set getDatabaseURIs();
 
   /**
-   * Generate the WHERE constraint equivalent to this FROM constraint. This
-   * method is really part of query resolution, and properly would belong in the
-   * resolver package.
-   *
-   * @param constraint the WHERE constraint which we want to further constraint
-   *      according to this FROM clause
-   * @param transformation localizing transformation
-   * @param modelProperty the local node representing the
-   *   <code>mulgara:model</code> property
-   * @param systemModel the local node representing the system model
-   *   (<code>#</code>)
-   * @param variableFactory a factory for anonymous link variables
-   * @return the expanded WHERE constraint, incorporating this FROM clause
-   * @throws TransformationException if <var>transformation</var> fails to
-   *      convert a model resource from the global (RDF) namespace
-   */
-  public ConstraintExpression toConstraintExpression(Constraint constraint,
-      Transformation transformation, Value modelProperty, Value systemModel,
-      VariableFactory variableFactory) throws TransformationException;
-
-  /**
    * Clones sets of models in the rhs and lhs objects.
    */
   public Object clone();

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelIntersection.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelIntersection.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelIntersection.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -70,33 +70,6 @@
   }
 
   /**
-   * METHOD TO DO
-   *
-   * @param constraint PARAMETER TO DO
-   * @param transformation PARAMETER TO DO
-   * @param modelProperty PARAMETER TO DO
-   * @param systemModel PARAMETER TO DO
-   * @param variableFactory PARAMETER TO DO
-   * @return RETURNED VALUE TO DO
-   * @throws TransformationException EXCEPTION TO DO
-   */
-  public ConstraintExpression toConstraintExpression(Constraint constraint,
-
-  // (s p o m)
-  Transformation transformation, Value modelProperty,
-  // mulgara:model
-  Value systemModel,
-  // #SYSTEM
-  VariableFactory variableFactory) throws TransformationException {
-
-    return new ConstraintConjunction(getLHS().toConstraintExpression(constraint,
-        transformation, modelProperty, systemModel, variableFactory),
-      getRHS().toConstraintExpression(constraint, transformation,
-        modelProperty, systemModel, variableFactory));
-  }
-
-
-  /**
    * Legible representation
    *
    * @return RETURNED VALUE TO DO

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelLiteral.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -148,44 +148,7 @@
     return in;
   }
 
-  /**
-   * @param constraint PARAMETER TO DO
-   * @param transformation PARAMETER TO DO
-   * @param modelProperty PARAMETER TO DO
-   * @param systemModel PARAMETER TO DO
-   * @param variableFactory PARAMETER TO DO
-   * @return RETURNED VALUE TO DO
-   * @throws UnsupportedOperationException always
-   */
-  public ConstraintExpression toConstraintExpression(Constraint constraint,
-      // (s p o m)
-      Transformation transformation, Value modelProperty,
-      // mulgara:model
-      Value systemModel,
-      // #SYSTEM
-      VariableFactory variableFactory) {
-
-    throw new UnsupportedOperationException(
-        "Literal models can't be converted to WHERE clauses yet");
-  }
-
   //
-  // Methods implementing Transformable
-  //
-
-  /**
-   * Transforms the constraints to/from global or local nodes.
-   *
-   * @param transformation The {@link Transformation} object to apply.
-   * @throws TransformationException If there was an error transforming.
-   */
-  public void transform(Transformation transformation) throws
-      TransformationException {
-
-    logger.warn("ModelLiteral.transform is not yet implemented");
-  }
-
-  //
   // Methods of Object
   //
 

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelOperation.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -146,40 +146,6 @@
   /**
    * METHOD TO DO
    *
-   * @param constraint PARAMETER TO DO
-   * @param transformation PARAMETER TO DO
-   * @param modelProperty PARAMETER TO DO
-   * @param systemModel PARAMETER TO DO
-   * @param variableFactory PARAMETER TO DO
-   * @return RETURNED VALUE TO DO
-   * @throws TransformationException EXCEPTION TO DO
-   */
-  public abstract ConstraintExpression toConstraintExpression(
-      Constraint constraint,
-      // (s p o m)
-      Transformation transformation,
-      Value modelProperty,
-      // mulgara:model
-      Value systemModel,
-      // #SYSTEM
-      VariableFactory variableFactory) throws TransformationException;
-
-  /**
-   * Transform the left and right hand sides of this operation.
-   *
-   * @param transformation the {@link Transformation} to apply
-   * @throws TransformationException if the transformation fails
-   */
-  public void transform(Transformation transformation) throws
-      TransformationException {
-
-    lhs.transform(transformation);
-    rhs.transform(transformation);
-  }
-
-  /**
-   * METHOD TO DO
-   *
    * @param m PARAMETER TO DO
    * @return RETURNED VALUE TO DO
    */

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelPartition.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -83,34 +83,6 @@
   }
 
   /**
-   * METHOD TO DO
-   *
-   * @param constraint PARAMETER TO DO
-   * @param transformation PARAMETER TO DO
-   * @param modelProperty PARAMETER TO DO
-   * @param systemModel PARAMETER TO DO
-   * @param variableFactory PARAMETER TO DO
-   * @return RETURNED VALUE TO DO
-   * @throws TransformationException EXCEPTION TO DO
-   */
-  public ConstraintExpression toConstraintExpression(Constraint constraint,
-
-  // (s p o m)
-  Transformation transformation, Value modelProperty,
-  // mulgara:model
-  Value systemModel,
-  // #SYSTEM
-  VariableFactory variableFactory) throws TransformationException {
-
-    logger.warn("Replacing partition operation with disjunction");
-
-    return new ConstraintDisjunction(getLHS().toConstraintExpression(constraint,
-        transformation, modelProperty, systemModel, variableFactory),
-      getRHS().toConstraintExpression(constraint, transformation,
-        modelProperty, systemModel, variableFactory));
-  }
-
-  /**
    * Legible representation
    *
    * @return RETURNED VALUE TO DO

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelResource.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelResource.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelResource.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -149,57 +149,7 @@
     return uri;
   }
 
-  /**
-   * METHOD TO DO
-   *
-   * @param constraint PARAMETER TO DO
-   * @param transformation PARAMETER TO DO
-   * @param modelProperty PARAMETER TO DO
-   * @param systemModel PARAMETER TO DO
-   * @param variableFactory PARAMETER TO DO
-   * @return RETURNED VALUE TO DO
-   * @throws TransformationException EXCEPTION TO DO
-   */
-  public ConstraintExpression toConstraintExpression(Constraint constraint,
-      // (s p o m)
-      Transformation transformation, Value modelProperty,
-      // mulgara:model
-      Value systemModel,
-      // #SYSTEM
-      VariableFactory variableFactory) throws TransformationException {
-
-    // Localize this model resource
-    Value model = transformation.transform(new URIReferenceImpl(uri));
-
-    // Generate the anonymous join variable $group
-    Variable group = variableFactory.newVariable();
-
-    // Return (s p o m) or ((s p o $group) and ($group mulgara:model m #SYSTEM))
-    return new ConstraintDisjunction(new ConstraintImpl(constraint.getElement(0),
-        constraint.getElement(1), constraint.getElement(2), model),
-        new ConstraintConjunction(new ConstraintImpl(constraint.getElement(0),
-        constraint.getElement(1), constraint.getElement(2), group),
-        new ConstraintImpl(group, modelProperty, model, systemModel)));
-  }
-
   //
-  // Methods implementing Transformable
-  //
-
-  /**
-   * Transforms the constraints to/from global or local nodes.
-   *
-   * @param transformation The {@link Transformation} object to apply.
-   * @throws TransformationException If there was an error transforming.
-   */
-  public void transform(Transformation transformation)
-      throws TransformationException {
-
-    // because ModelResource currently wraps a URI rather than a Value,
-    // no transformation is required
-  }
-
-  //
   // Methods extending Object
   //
 

Modified: trunk/src/jar/query/java/org/mulgara/query/ModelUnion.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/ModelUnion.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/query/java/org/mulgara/query/ModelUnion.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -70,32 +70,6 @@
   }
 
   /**
-   * METHOD TO DO
-   *
-   * @param constraint PARAMETER TO DO
-   * @param transformation PARAMETER TO DO
-   * @param modelProperty PARAMETER TO DO
-   * @param systemModel PARAMETER TO DO
-   * @param variableFactory PARAMETER TO DO
-   * @return RETURNED VALUE TO DO
-   * @throws TransformationException EXCEPTION TO DO
-   */
-  public ConstraintExpression toConstraintExpression(Constraint constraint,
-
-  // (s p o m)
-  Transformation transformation, Value modelProperty,
-  // mulgara:model
-  Value systemModel,
-  // #SYSTEM
-  VariableFactory variableFactory) throws TransformationException {
-
-    return new ConstraintDisjunction(getLHS().toConstraintExpression(constraint,
-        transformation, modelProperty, systemModel, variableFactory),
-      getRHS().toConstraintExpression(constraint, transformation,
-        modelProperty, systemModel, variableFactory));
-  }
-
-  /**
    * Legible representation
    *
    * @return RETURNED VALUE TO DO

Modified: trunk/src/jar/query/java/org/mulgara/query/Query.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/Query.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/query/java/org/mulgara/query/Query.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -207,7 +207,35 @@
     this.answer = answer;
   }
 
+ 
   /**
+   * Construct a new query equivalent to substituing 'where' for the
+   * where-clause in the original query.
+   */
+  public Query(Query query, ConstraintExpression where) {
+    logger.warn("Creating new query from: " + System.identityHashCode(query), new Throwable());
+    this.mutableVariableList = query.mutableVariableList;
+    this.variableList = query.variableList;
+    this.modelExpression = query.modelExpression;
+    this.constraintExpression = where;
+    this.havingConstraint = query.havingConstraint;
+    this.orderList = query.orderList;
+    this.limit = query.limit;
+    this.offset = query.offset;
+    this.answer = (Answer)query.answer.clone();
+    /*
+      this(query.getVariableList(),
+          query.getModelExpression(),
+          where,
+          query.getHavingExpression(),
+          query.getOrderList(),
+          query.getLimit(),
+          query.getOffset(),
+          (Answer)query.getGiven().clone());
+    */
+  }
+
+  /**
    * Cloning must always be supported.
    */
   public Object clone() {
@@ -221,11 +249,26 @@
     }
 
     // Copy mutable fields by value
-    cloned.mutableVariableList =
-        (variableList == null) ? null : new ArrayList(variableList);
-    cloned.variableList =
-        (variableList == null) ? null
-        : Collections.unmodifiableList(cloned.mutableVariableList);
+    if (variableList == null) {
+      cloned.mutableVariableList = null;
+      cloned.variableList = null;
+    } else {
+      cloned.variableList = new ArrayList();
+      Iterator i = variableList.iterator();
+      while (i.hasNext()) {
+        Object o = i.next();
+        if (o instanceof Subquery) {
+          Subquery s = (Subquery)o;
+          cloned.variableList.add(new Subquery(s.getVariable(), (Query)s.getQuery().clone()));
+        } else if (o instanceof Count) {
+          Count a = (Count)o;
+          cloned.variableList.add(new Count(a.getVariable(), (Query)a.getQuery().clone()));
+        } else {
+          cloned.variableList.add(o);
+        }
+      }
+      cloned.mutableVariableList = Collections.unmodifiableList(cloned.variableList);
+    }
     cloned.modelExpression = modelExpression;  // FIXME: should be cloned
     cloned.answer = (Answer) answer.clone();
 
@@ -417,6 +460,7 @@
    * Close this {@link Query}, and the underlying {@link Answer} objects.
    */
   public void close() throws TuplesException {
+    logger.warn("Query: " + System.identityHashCode(this) + " closed", new Throwable());
     answer.close();
     answer = null;
 

Deleted: trunk/src/jar/query/java/org/mulgara/query/Transformable.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/Transformable.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/query/java/org/mulgara/query/Transformable.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -1,68 +0,0 @@
-/*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
- */
-
-package org.mulgara.query;
-
-
-// Java 2 standard packages
-import java.io.Serializable;
-
-/**
- * An interface marking the capability to globalize and localize data structures
- * built from {@link Value}s. <p>
- *
- * The entire point of localization and globalization is to be able to ship
- * classes to different sites. This is the reason this interface extends {@link
- * Serializable}. </p>
- *
- * @created 2001-08-13
- *
- * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
- *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:20 $ by $Author: newmana $
- *
- * @maintenanceAuthor $Author: newmana $
- *
- * @copyright &copy;2001-2003
- *   <a href="http://www.pisoftware.com/">Plugged In Software Pty Ltd</a>
- *
- * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
- */
-public interface Transformable extends Serializable {
-
-  /**
-   * Transform all the {@link Value}s in this instance.
-   *
-   * @param transformation a {@link Transformation} from the current type to the
-   *      desired type
-   * @throws TransformationException if the transformation can't be performed
-   */
-  public void transform(Transformation transformation)
-    throws TransformationException;
-}

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/AppendAggregateTuples.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -72,14 +72,14 @@
   /**
    * The aggregate functions extracted from the <code>SELECT</code> clause.
    */
-  private List localQueryList;
+  private List<Query> queryList;
 
   /**
    * Whether the corresponding index of this instance is an index into
-   * the {@link #localQueryList} (if <code>true</code>) or the wrapped
+   * the {@link #queryList} (if <code>true</code>) or the wrapped
    * {@link #tuples} (if <code>false</code>).
    */
-  private boolean[] columnIsLocalQuery;
+  private boolean[] columnIsAggregate;
 
   private int[] columnAggregateIndex;
 
@@ -95,6 +95,9 @@
   /** Whether the {@link #cache} is valid for the current row.  */
   private boolean[] isCacheValid;
 
+  /** Exists *only* so we can call resolveMap() */
+  private LocalQueryResolver context;
+
   /**
    * Wrap an {@link Answer} instance.
    *
@@ -109,7 +112,7 @@
    * @throws TuplesException  if there's trouble reading <var>tuples</var>
    */
   AppendAggregateTuples(ResolverSession session,
-      DatabaseOperationContext context, Tuples tuples,
+      LocalQueryResolver context, Tuples tuples,
       List variableList) throws TuplesException {
     if (logger.isDebugEnabled()) {
       logger.debug("Generating variable list for " + tuples + " and " +
@@ -124,7 +127,8 @@
     }
 
     // Initialize fields
-    this.columnIsLocalQuery = new boolean[variableList.size()];
+    this.context = context;
+    this.columnIsAggregate = new boolean[variableList.size()];
     this.columnAggregateIndex = new int[variableList.size()];
     this.session = session;
     this.tuples = (Tuples) tuples.clone();
@@ -141,7 +145,7 @@
       if (logger.isDebugEnabled()) {
         logger.debug("" + hashCode() + " columnAggregateIndex[" + i + "] = -1");
       }
-      columnIsLocalQuery[i] = false;
+      columnIsAggregate[i] = false;
     }
     if (logger.isDebugEnabled()) {
       logger.debug("" + hashCode() + " tupleVars.length = " + tupleVars.length);
@@ -149,7 +153,7 @@
 
     // Calculate the rest of the variable list
     int aggregateIndex = 0;
-    localQueryList = new ArrayList();
+    queryList = new ArrayList<Query>();
     for (int i = 0; i < variableList.size(); i++) {
       Object element = variableList.get(i);
       if (element instanceof Count) {
@@ -160,17 +164,11 @@
               tupleVars.length + aggregateIndex + "] = " + aggregateIndex);
         }
         newVariableList.add(((Count) element).getVariable());
-        columnIsLocalQuery[tupleVars.length + aggregateIndex] = true;
+        columnIsAggregate[tupleVars.length + aggregateIndex] = true;
         aggregateIndex++;
 
-        try {
-          Query query = ((Count) element).getQuery();
-          localQueryList.add(new LocalQuery(query, session, context));
-        }
-        catch (LocalizeException e) {
-          throw new TuplesException(
-              "Couldn't localize aggregate function query " + element, e);
-        }
+        Query query = ((Count)element).getQuery();
+        queryList.add((Query)query.clone());
       }
     }
 
@@ -184,8 +182,8 @@
       logger.debug("Set variable list " + Arrays.asList(getVariables()));
     }
 
-    // Initialize cache fields dependent on localQueryList
-    cache = new long[localQueryList.size()];
+    // Initialize cache fields dependent on queryList
+    cache = new long[queryList.size()];
     isCacheValid = new boolean[cache.length];
   }
 
@@ -212,18 +210,17 @@
     AppendAggregateTuples cloned = (AppendAggregateTuples)super.clone();
 
     cloned.session = session;
-    cloned.columnIsLocalQuery = cloned.columnIsLocalQuery;
+    cloned.columnIsAggregate = cloned.columnIsAggregate;
     cloned.tuples = (Tuples) tuples.clone();
     cloned.cache = (long[]) cache.clone();
     cloned.isCacheValid = (boolean[]) isCacheValid.clone();
-    cloned.localQueryList = new ArrayList();
-    for (Iterator i = localQueryList.iterator(); i.hasNext(); ) {
-      cloned.localQueryList.add(((LocalQuery) i.next()).clone());
+    cloned.queryList = new ArrayList<Query>();
+    for (Query query : queryList) {
+      cloned.queryList.add((Query)query.clone());
     }
 
     if (logger.isDebugEnabled()) {
-      logger.debug("AppendAggregateTuples clone " + cloned.hashCode() +
-          " from " + hashCode());
+      logger.debug("AppendAggregateTuples clone " + cloned.hashCode() + " from " + hashCode());
     }
     return cloned;
   }
@@ -232,18 +229,11 @@
     if (logger.isDebugEnabled()) {
       logger.debug("closing AppendAggregateTuples " + hashCode(), new Throwable());
     }
-    for (Iterator i = localQueryList.iterator(); i.hasNext(); ) {
-      LocalQuery lc = ((LocalQuery) i.next());
+    for (Query query : queryList) {
       if (logger.isDebugEnabled()) {
-        logger.debug("AppendAggregateTuples " + hashCode() +
-            " closing LocalQuery " + lc.hashCode());
+        logger.debug("AppendAggregateTuples " + hashCode() + " closing Query " + query.hashCode());
       }
-      try {
-        lc.close();
-      }
-      catch (QueryException eq) {
-        throw new TuplesException("Error closing subquery", eq);
-      }
+      query.close();
     }
 
     tuples.close();
@@ -268,14 +258,14 @@
       try {
         // Add the values of the current row to the WHERE clause of the
         // aggregate function's query
-        LocalQuery localQuery = (LocalQuery) localQueryList.get(index);
+        Query query = queryList.get(index);
 
         if (logger.isDebugEnabled()) {
-          logger.debug("" + hashCode() + " Base aggregate query: " + localQuery);
+          logger.debug("" + hashCode() + " Base aggregate query: " + query);
         }
 
         // Evaluate the aggregate query
-        Tuples tuples = localQuery.resolve(createBindingMap(this.tuples));
+        Tuples tuples = context.resolveMap(query, createBindingMap(this.tuples));
 
         if (logger.isDebugEnabled()) {
           logger.debug("Resolved aggregate to " + tuples);
@@ -311,8 +301,8 @@
     Map bindings = new HashMap();
     Variable[] vars = tuples.getVariables();
 
-    for (int i = 0; i < columnIsLocalQuery.length; i++) {
-      if (!columnIsLocalQuery[i]) {
+    for (int i = 0; i < columnIsAggregate.length; i++) {
+      if (!columnIsAggregate[i]) {
         long columnValue = tuples.getColumnValue(i);
         if (columnValue != Tuples.UNBOUND) {
           bindings.put(vars[i], new LocalNode(columnValue));

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/Database.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/Database.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/Database.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -1242,7 +1242,7 @@
       setter.invoke(null, new Object[] { names });
     } catch (Exception e) {
       /* Not much that can be done here */
-      logger.warn("Unable to set the host names for Server Info", e);
+      logger.info("Unable to set the host names for Server Info", e);
     }
   }
 }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -770,19 +770,19 @@
     return tuples;
   }
 
-  Tuples innerCount(LocalQuery localQuery) throws QueryException {
-    if (localQuery == null) {
+  Tuples innerCount(Query query) throws QueryException {
+    if (query == null) {
       throw new IllegalArgumentException("Null \"query\" parameter");
     }
 
     if (logger.isInfoEnabled()) {
-      logger.info("Inner Count: " + localQuery);
+      logger.info("Inner Count: " + query);
     }
     try {
-      LocalQuery lq = (LocalQuery)localQuery.clone();
-      transform(lq);
-      Tuples result = lq.resolve();
-      lq.close();
+      query = transform(query);
+      LocalQuery lq = new LocalQuery(systemResolver, this);
+      Tuples result = lq.resolveE(query);
+      query.close();
 
       return result;
     } catch (QueryException eq) {
@@ -830,51 +830,55 @@
   {
     TransactionalAnswer result;
 
-    LocalQuery localQuery = new LocalQuery(query, systemResolver, this);
+    query = transform(query);
 
-    transform(localQuery);
+    LocalQuery localQuery = new LocalQuery(systemResolver, this);
 
     // Complete the numerical phase of resolution
-    Tuples tuples = localQuery.resolve();
+    Tuples tuples = localQuery.resolveE(query);
     result = new TransactionalAnswer(transaction, new SubqueryAnswer(this, systemResolver, tuples, query.getVariableList()));
     answers.put(result, null);
     tuples.close();
-    localQuery.close();
 
     return result;
   }
 
   /**
-   *
-   * Perform in-place transformation of localQuery.
-   * Note: we really want to convert this to a functional form eventually.
+   * Apply the registered transformations to the query until we reach a
+   * fixed-point.
    */
-  void transform(LocalQuery localQuery) throws Exception {
+  Query transform(Query query) throws Exception {
     // Start with the symbolic phase of resolution
-    LocalQuery.MutableLocalQueryImpl mutableLocalQueryImpl =
-      localQuery.new MutableLocalQueryImpl();
     if (symbolicLogger.isDebugEnabled()) {
-      symbolicLogger.debug("Before transformation: " + mutableLocalQueryImpl);
+      symbolicLogger.debug("Before transformation: " + query);
     }
+
+    MutableLocalQueryImpl mutable = new MutableLocalQueryImpl(query);
     Iterator i = symbolicTransformationList.iterator();
     while (i.hasNext()) {
-      SymbolicTransformation symbolicTransformation =
-        (SymbolicTransformation) i.next();
+      SymbolicTransformation symbolicTransformation = (SymbolicTransformation)i.next();
       assert symbolicTransformation != null;
-      symbolicTransformation.transform(this, mutableLocalQueryImpl);
-      if (mutableLocalQueryImpl.isModified()) {
-        // When a transformation succeeds, we rewind and start from the
-        // beginning of the symbolicTransformationList again
+
+      symbolicTransformation.transform(this, mutable);
+
+      // When a transformation succeeds, we rewind and start from the
+      // beginning of the symbolicTransformationList again
+      if (mutable.isModified()) {
         if (symbolicLogger.isDebugEnabled()) {
-          symbolicLogger.debug("Symbolic transformation: " +
-                               mutableLocalQueryImpl);
+          symbolicLogger.debug("Symbolic transformation: " + mutable);
         }
-        mutableLocalQueryImpl.close();
-        mutableLocalQueryImpl = localQuery.new MutableLocalQueryImpl();
+
+        Query tmp = query;
+        query = new Query(query, mutable.getConstraintExpression());
+        tmp.close();
+
+        mutable = new MutableLocalQueryImpl(query);
+
         i = symbolicTransformationList.iterator();
       }
     }
-    mutableLocalQueryImpl.close();
+
+    return query;
   }
 
   void clear() throws QueryException {

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQuery.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQuery.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQuery.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -43,7 +43,6 @@
 import org.mulgara.resolver.spi.GlobalizeException;
 import org.mulgara.resolver.spi.LocalizeException;
 import org.mulgara.resolver.spi.LocalizedTuples;
-import org.mulgara.resolver.spi.MutableLocalQuery;
 import org.mulgara.resolver.spi.QueryEvaluationContext;
 import org.mulgara.resolver.spi.ResolverSession;
 import org.mulgara.resolver.spi.SymbolicTransformation;
@@ -77,33 +76,8 @@
   /** The current localisation/globalisation session.  */
   private final ResolverSession resolverSession;
 
-  /** The session this query is local to.  */
-  private final DatabaseOperationContext context;
+  private LocalQueryResolver context;
 
-  /** The constraint expression. */
-  private ConstraintExpression constraintExpression;
-
-  /** The model expression. */
-  private ModelExpression modelExpression;
-
-  /** The having clause */
-  private ConstraintHaving having;
-
-  /** The various components of the select clause. */
-  private final List orderList;
-  private final int offset;
-  private final Integer limit;
-  private Tuples given;
-
-  /** Variable list from select clause */
-  private List select;
-
-  private Map cachedResults;
-
-  //
-  // Constructor
-  //
-
   /**
    * Construct a database.
    *
@@ -114,146 +88,54 @@
    *   <var>resolverSession</var> are <code>null</code>
    * @throws LocalizeException if the <var>query</var> can't be localized
    */
-  LocalQuery(Query query, ResolverSession resolverSession, DatabaseOperationContext context)
+  LocalQuery(ResolverSession resolverSession, DatabaseOperationContext context)
     throws LocalizeException, TuplesException
   {
-    if (logger.isDebugEnabled()) {
-      logger.debug("Constructing local query for " + query);
-    }
-
-    // Validate "query" parameter
-    if (query == null) {
-      throw new IllegalArgumentException("Null \"query\" parameter");
-    }
-
     // Validate "resolverSession" parameter
     if (resolverSession == null) {
       throw new IllegalArgumentException("Null \"resolverSession\" parameter");
     }
 
     // Initialize fields
-    this.constraintExpression = query.getConstraintExpression();
+    this.context = new LocalQueryResolver(context, resolverSession);
     this.resolverSession = resolverSession;
-    this.context = context;
-    this.modelExpression = (ModelExpression)query.getModelExpression().clone();
-    this.orderList = query.getOrderList();
-    this.offset = query.getOffset();
-    this.limit = query.getLimit();
-    this.given = new LocalizedTuples(resolverSession, query.getGiven());
-    this.having = query.getHavingExpression();
-    this.select = query.getVariableList();
-    this.cachedResults = new HashMap();
-
     if (logger.isDebugEnabled()) {
       logger.debug("Constructed local query");
     }
   }
 
-  LocalQuery(LocalQuery localQuery, ConstraintExpression constraintExpression) {
-    this.constraintExpression = constraintExpression;
-    this.resolverSession = localQuery.resolverSession;
-    this.context = localQuery.context;
-    this.modelExpression = localQuery.modelExpression;
-    this.orderList = localQuery.orderList;
-    this.offset = localQuery.offset;
-    this.limit = localQuery.limit;
-    this.given = (Tuples)localQuery.given.clone();
-    this.select = localQuery.select;
-    this.cachedResults = new HashMap();
-  }
-
-  //
-  // API methods
-  //
-
   /**
-   * Attempt to apply a symbolic query transformation.
-   *
-   * Symbolic transformations modify the values of query clauses without
-   * resolving any {@link Constraint} into {@link Tuples}.
-   *
-   * @param symbolicTransformation  the transformation to apply, never
-   *   <code>null</code>
-   * @return <code>true</code> if the application modified this instance
+   * @return the solution to this query
+   * @throws QueryException if resolution can't be obtained
    */
-  boolean apply(SymbolicTransformation symbolicTransformation)
-    throws QueryException
+  Tuples resolveE(Query query) throws QueryException
   {
-    /*
-    MutableLocalQuery mutableLocalQuery = this.new MutableLocalQueryImpl();
-    symbolicTransformation.apply(mutableLocalQuery);
-    return mutableLocalQuery.isModified();
-    */
-    return false;
-  }
-
-  Tuples resolve(Map outerBindings) throws QueryException
-  {
-    try {
-      return context.innerCount(new LocalQuery(this,
-          new ConstraintConjunction(ConstraintOperations.bindVariables(outerBindings, constraintExpression),
-                                    constrainBindings(outerBindings))));
-    } catch (LocalizeException el) {
-      throw new QueryException("Failed to resolve inner local query", el);
+    if (query == null) {
+      throw new IllegalArgumentException("Query null in LocalQuery::resolveE");
     }
-  }
 
-
-  // FIXME: This method should be using a LiteralTuples.  Also I believe MULGARA_IS is now preallocated.
-  // Someone needs to try making the change and testing.
-  private ConstraintExpression constrainBindings(Map bindings) throws LocalizeException {
-    List args = new ArrayList();
-    Iterator i = bindings.entrySet().iterator();
-    logger.info("FIXME:localize should be lookup, need to preallocate MULGARA_IS");
-    while (i.hasNext()) {
-      Map.Entry entry = (Map.Entry)i.next();
-      args.add(ConstraintIs.newLocalConstraintIs(
-                  (Variable)entry.getKey(),
-                  new LocalNode(resolverSession.localize(ConstraintIs.MULGARA_IS)),
-                  (Value)entry.getValue(),
-                  null));
-    }
-
-    return new ConstraintConjunction(args);
-  }
-
-
-  Tuples resolve(ConstraintExpression whereExtension) throws QueryException {
-    return resolve(constraintExpression, whereExtension);
-  }
-
-
-  Tuples resolve(Constraint constraint) throws QueryException {
-    return context.resolve(constraint);
-  }
-
-
-  Tuples resolve(ConstraintExpression baseExpression, ConstraintExpression whereExtension) throws QueryException
-  {
     try {
       if (logger.isDebugEnabled()) {
-        logger.debug("Resolving query " + modelExpression + " . " + constraintExpression);
+        logger.debug("Resolving query " + query);
       }
 
       if (logger.isDebugEnabled()) {
         logger.debug("Stacktrace: ", new Throwable());
       }
 
-      ConstraintExpression tmpConstraint = new ConstraintConjunction(
-          whereExtension, baseExpression);
+      Tuples result = ConstraintOperations.resolveConstraintExpression(context,
+          query.getModelExpression(), query.getConstraintExpression());
 
-      Tuples result = resolve(modelExpression, tmpConstraint);
-
       if (logger.isDebugEnabled()) {
         logger.debug("Tuples result = " + TuplesOperations.formatTuplesTree(result));
       }
 
-      result = projectSelectClause(result);
-      result = appendAggregates(result);
-      result = applyHaving(result);
-      result = orderResult(result);
-      result = offsetResult(result);
-      result = limitResult(result);
+      result = projectSelectClause(query, result);
+      result = appendAggregates(query, result);
+      result = applyHaving(query, result);
+      result = orderResult(query, result);
+      result = offsetResult(query, result);
+      result = limitResult(query, result);
 
       return result;
     } catch (TuplesException et) {
@@ -262,30 +144,12 @@
   }
 
 
-  /**
-   * @return the solution to this query
-   * @throws QueryException if resolution can't be obtained
-   */
-  Tuples resolve() throws QueryException
+  private Tuples projectSelectClause(Query query, Tuples result) throws TuplesException
   {
-    try {
-      return resolve(new ConstraintConjunction(new ArrayList()));
-    } catch (QueryException eq) {
-      logger.warn("QueryException thrown in resolve: ", eq);
-      throw eq;
-    } catch (Exception e) {
-      logger.warn("Exception thrown in resolve: ", e);
-      throw new QueryException("Exception thrown in resolve", e);
-    }
-  }
-
-
-  private Tuples projectSelectClause(Tuples result) throws TuplesException
-  {
     if (result.getRowCardinality() > Cursor.ZERO) {
       Tuples tmp = result;
       try {
-        List variables = new ArrayList(select.size());
+        List variables = new ArrayList();
 
       /*
        * Note that this code need not concern itself with the order of the select-list,
@@ -295,7 +159,7 @@
        */
         Variable[] vars = result.getVariables();
         for (int i = 0; i < vars.length; i++) {
-          if (select.contains(vars[i])) {
+          if (query.getVariableList().contains(vars[i])) {
             variables.add(vars[i]);
           }
         }
@@ -310,11 +174,12 @@
   }
 
 
-  private Tuples appendAggregates(Tuples result) throws TuplesException
+  private Tuples appendAggregates(Query query, Tuples result) throws TuplesException
   {
     if (result.getRowCardinality() != Tuples.ZERO) {
       Tuples tmp = result;
-      result = new AppendAggregateTuples(resolverSession, context, result, filterSubqueries(select));
+      result = new AppendAggregateTuples(resolverSession, context, result,
+          filterSubqueries(query.getVariableList()));
       tmp.close();
     }
 
@@ -323,9 +188,7 @@
 
   private List filterSubqueries(List select) {
     List result = new ArrayList();
-    Iterator i = select.iterator();
-    while (i.hasNext()) {
-      Object o = i.next();
+    for (Object o : select) {
       if (!(o instanceof Subquery)) {
         result.add(o);
       }
@@ -335,7 +198,8 @@
   }
 
 
-  private Tuples applyHaving(Tuples result) throws TuplesException {
+  private Tuples applyHaving(Query query, Tuples result) throws TuplesException {
+    ConstraintHaving having = query.getHavingExpression();
     Tuples tmp = result;
     if (having != null) {
       result = TuplesOperations.restrict(
@@ -347,7 +211,8 @@
   }
 
 
-  private Tuples orderResult(Tuples result) throws TuplesException, QueryException {
+  private Tuples orderResult(Query query, Tuples result) throws TuplesException, QueryException {
+    List orderList = query.getOrderList();
     if (orderList.size() > 0 && result.getRowCardinality() > Cursor.ONE) {
       Tuples tmp = result;
       result = TuplesOperations.sort(result,
@@ -358,8 +223,9 @@
     return result;
   }
 
-  private Tuples offsetResult(Tuples result) throws TuplesException
+  private Tuples offsetResult(Query query, Tuples result) throws TuplesException
   {
+    int offset = query.getOffset();
     if (offset > 0) {
       Tuples tmp = result;
       result = TuplesOperations.offset(result, offset);
@@ -370,8 +236,9 @@
   }
 
 
-  private Tuples limitResult(Tuples result)  throws TuplesException
+  private Tuples limitResult(Query query, Tuples result)  throws TuplesException
   {
+    Integer limit = query.getLimit();
     if (limit != null) {
       Tuples tmp = result;
       result = TuplesOperations.limit(result, limit.intValue());
@@ -380,120 +247,4 @@
 
     return result;
   }
-
-  //
-  // Internal methods
-  //
-
-  /**
-   * Localize and resolve the <code>FROM</code> and <code>WHERE</code> clause
-   * product.
-   *
-   * @param modelExpression the <code>FROM<code> clause to resolve
-   * @param constraintExpression the <code>WHERE</code> clause to resolve
-   * @throws QueryException if resolution can't be obtained
-   */
-  Tuples resolve(ModelExpression      modelExpression,
-                 ConstraintExpression constraintExpression)
-    throws QueryException
-  {
-    QueryEvaluationContext context = new LocalQueryResolver(this, resolverSession);
-
-    return ConstraintOperations.resolveConstraintExpression(context, modelExpression, constraintExpression);
-  }
-
-
-  ResolverSession getResolverSession() {
-    return resolverSession;
-  }
-
-
-  public Object clone()
-  {
-    try {
-      LocalQuery query = (LocalQuery)super.clone();
-      query.modelExpression = (ModelExpression)modelExpression.clone();
-      query.given = (Tuples)given.clone();
-
-      return query;
-    } catch (CloneNotSupportedException ec) {
-      throw new Error("Object threw CloneNotSupportedException", ec);
-    }
-  }
-
-
-  public void close() throws QueryException
-  {
-    try {
-      given.close();
-    } catch (TuplesException et) {
-      throw new QueryException("Failed to close given clause", et);
-    }
-  }
-
-  public String toString()
-  {
-    return "where " + constraintExpression;
-  }
-
-  /**
-   * Mutator for {@link LocalQuery}.
-   */
-  class MutableLocalQueryImpl implements MutableLocalQuery
-  {
-    private boolean closed = false;
-    private boolean modified = false;
-
-    /**
-     * Once called, this instance can no longer be used for modifications.
-     */
-    void close()
-    {
-      closed = true;
-    }
-
-    /**
-     * @return whether this instance has been used to mutate the value of the
-     *   outer class
-     */
-    boolean isModified()
-    {
-      return modified;
-    }
-
-    //
-    // Methods implementing LocalQuery
-    //
-
-    public ConstraintExpression getConstraintExpression()
-    {
-      return constraintExpression;
-    }
-
-    public void setConstraintExpression(ConstraintExpression constraintExpression)
-    {
-      // Validate state
-      if (closed) {
-        throw new IllegalStateException();
-      }
-
-      // Validate "constraintExpression" parameter
-      if (constraintExpression == null) {
-        throw new IllegalArgumentException("Null \"constraintExpression\" parameter");
-      }
-
-      // Update fields
-      LocalQuery.this.constraintExpression = constraintExpression;
-      modified = true;
-    }
-
-    //
-    // Methods overriding Object
-    //
-
-    public String toString()
-    {
-      return LocalQuery.this.toString();
-    }
-  }
 }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/LocalQueryResolver.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -93,32 +93,20 @@
   /** Logger.  */
   private static final Logger logger = Logger.getLogger(LocalQueryResolver.class.getName());
 
-  private LocalQuery localQuery;
+  private DatabaseOperationContext operationContext;
 
   private ResolverSession resolverSession;
 
   //
   // Constructor
   //
-
-  /**
-   * Construct a database.
-   *
-   * @param localQuery  the query to localize
-   * @param resolverSession  the database session to localize the
-   *   <var>localQuery</var> against
-   * @throws IllegalArgumentException if <var>query</var> or
-   *   <var>resolverSession</var> are <code>null</code>
-   * @throws LocalizeException if the <var>query</var> can't be localized
-   */
-  LocalQueryResolver(LocalQuery localQuery, ResolverSession resolverSession) {
-    // Validate "query" parameter
-    if (localQuery == null) {
-      throw new IllegalArgumentException("Null 'localQuery' parameter");
+  LocalQueryResolver(DatabaseOperationContext operationContext, ResolverSession resolverSession) {
+    if (operationContext == null) {
+      throw new IllegalArgumentException("Null 'operationContext' parameter");
     }
 
     // Initialize fields
-    this.localQuery = localQuery;
+    this.operationContext = operationContext;
     this.resolverSession = resolverSession;
   }
 
@@ -462,7 +450,7 @@
             localize(new URIReferenceImpl(modelResource.getURI())), localized);
       }
 
-      Tuples result = localQuery.resolve(localized);
+      Tuples result = operationContext.resolve(localized);
 
       return result;
     } catch (LocalizeException e) {
@@ -477,11 +465,51 @@
 
 
   public Tuples resolve(ModelExpression modelExpression, ConstraintExpression constraintExpression) throws QueryException {
-    return localQuery.resolve(modelExpression, constraintExpression);
+    return ConstraintOperations.resolveConstraintExpression(this, modelExpression, constraintExpression);
   }
 
 
   public ResolverSession getResolverSession() {
     return resolverSession;
   }
+
+  Tuples resolveMap(Query query, Map outerBindings) throws QueryException
+  {
+    try {
+      Query newQuery = new Query(
+          query.getVariableList(),
+          query.getModelExpression(),
+          new ConstraintConjunction(
+              ConstraintOperations.bindVariables(outerBindings, query.getConstraintExpression()),
+              constrainBindings(outerBindings)),
+          query.getHavingExpression(),
+          query.getOrderList(),
+          query.getLimit(),
+          query.getOffset(),
+          (Answer)query.getGiven().clone());
+          
+      return operationContext.innerCount(newQuery);
+    } catch (LocalizeException el) {
+      throw new QueryException("Failed to resolve inner local query", el);
+    }
+  }
+
+
+  // FIXME: This method should be using a LiteralTuples.  Also I believe MULGARA_IS is now preallocated.
+  // Someone needs to try making the change and testing.
+  private ConstraintExpression constrainBindings(Map bindings) throws LocalizeException {
+    List args = new ArrayList();
+    Iterator i = bindings.entrySet().iterator();
+    logger.info("FIXME:localize should be lookup, need to preallocate MULGARA_IS");
+    while (i.hasNext()) {
+      Map.Entry entry = (Map.Entry)i.next();
+      args.add(ConstraintIs.newLocalConstraintIs(
+                  (Variable)entry.getKey(),
+                  new LocalNode(resolverSession.localize(ConstraintIs.MULGARA_IS)),
+                  (Value)entry.getValue(),
+                  null));
+    }
+
+    return new ConstraintConjunction(args);
+  }
 }

Copied: trunk/src/jar/resolver/java/org/mulgara/resolver/MutableLocalQueryImpl.java (from rev 422, branches/mgr-69/src/jar/resolver/java/org/mulgara/resolver/MutableLocalQueryImpl.java)

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/SubqueryAnswer.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/SubqueryAnswer.java	2007-09-11 10:28:13 UTC (rev 424)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/SubqueryAnswer.java	2007-09-11 12:33:31 UTC (rev 425)
@@ -288,14 +288,7 @@
           ConstraintOperations.bindVariables(bindings, query.getConstraintExpression()),
           constrainBindings(bindings));
 
-      query = new Query(query.getVariableList(),
-          query.getModelExpression(),
-          where,
-          null,
-          query.getOrderList(),
-          query.getLimit(),
-          query.getOffset(),
-          query.getGiven());
+      query = new Query(query, where);
 
       if (logger.isDebugEnabled()) {
         logger.debug("Generated subquery: " + query);




More information about the Mulgara-svn mailing list