You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pp...@apache.org on 2011/12/23 20:55:46 UTC

svn commit: r1222818 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: kernel/PreparedQueryImpl.java sql/BindParameter.java sql/DBDictionary.java sql/LogicalUnion.java sql/SQLBuffer.java sql/Select.java sql/SelectImpl.java

Author: ppoddar
Date: Fri Dec 23 19:55:46 2011
New Revision: 1222818

URL: http://svn.apache.org/viewvc?rev=1222818&view=rev
Log:
OPENJPA-2099: Introduce bind parameter. Remove direct string appending to Select

Added:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/BindParameter.java   (with props)
Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java?rev=1222818&r1=1222817&r2=1222818&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java Fri Dec 23 19:55:46 2011
@@ -32,6 +32,7 @@ import org.apache.openjpa.jdbc.meta.Clas
 import org.apache.openjpa.jdbc.meta.FieldMapping;
 import org.apache.openjpa.jdbc.meta.MappingRepository;
 import org.apache.openjpa.jdbc.schema.Column;
+import org.apache.openjpa.jdbc.sql.BindParameter;
 import org.apache.openjpa.jdbc.sql.LogicalUnion;
 import org.apache.openjpa.jdbc.sql.SQLBuffer;
 import org.apache.openjpa.jdbc.sql.SelectExecutor;
@@ -430,10 +431,10 @@ public class PreparedQueryImpl implement
         }
     }
     
-    void setParameters(List list) {
+    void setParameters(List<BindParameter> list) {
         Map<Integer, Object> tmp = new HashMap<Integer, Object>();
         for (int i = 0; list != null && i < list.size(); i++) {
-            tmp.put(i, list.get(i));
+            tmp.put(i, list.get(i).getValue());
         }
         _template = Collections.unmodifiableMap(tmp);
     }

Added: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/BindParameter.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/BindParameter.java?rev=1222818&view=auto
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/BindParameter.java (added)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/BindParameter.java Fri Dec 23 19:55:46 2011
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.jdbc.sql;
+
+import org.apache.openjpa.jdbc.schema.Column;
+
+
+/**
+ * A binding parameter in a SQL statement.
+ * <br>
+ * A binding parameter is used in <tt>WHERE<tt> clause. The parameter is identified by an
+ * immutable key and has a value. The parameter is further qualified by whether it is
+ * user specified (e.g. from a query parameter) or internally generated (e.g. a discriminator
+ * value for inheritance join). A database column can also be optionally associated with 
+ * a binding parameter.
+ * 
+ * @see SQLBuffer#appendValue(Object, Column, org.apache.openjpa.kernel.exps.Parameter)
+ * 
+ * @author Pinaki Poddar
+ *
+ */
+public class BindParameter {
+	// Is this parameter specified by user or our own runtime
+	private final boolean _user;
+	// the column
+	private final Column  _column;
+	// key of this parameter
+	private final Object  _key;
+	private Object _value;
+	
+	/**
+	 * Constructs a parameter with given key, column and user flag.
+	 * 
+	 * @param key the identifier. Can be null only if not a user-defined parameter.
+	 * @param user flags if this key is originally specified by the user. 
+	 * @param column a column represented by this parameter. Can be null.
+	 */
+	public BindParameter(Object key, boolean user, Column column, Object value) {
+		super();
+		if (user && key == null)
+			throw new IllegalArgumentException("User-defined parameter can not have null key");
+		_key = key;
+		_user = user;
+		_column = column;
+		_value  = value;
+	}
+	
+	/**
+	 * Gets the value bound to this parameter. Can be null.
+	 */
+	public Object getValue() {
+		return _value;
+	}
+	
+	/**
+	 * Binds the given value to this parameter. Can be null.
+	 */
+	public void setValue(Object value) {
+		_value = value;
+	}
+
+	/**
+	 * Affirms if this parameter is specified by the user.
+	 */
+	public boolean isUser() {
+		return _user;
+	}
+
+	/**
+	 * Gets the column associated with this parameter, if any.
+	 */
+	public Column getColumn() {
+		return _column;
+	}
+
+	/**
+	 * Gets the key associated with this parameter.
+	 * The user-defined parameter must have a non-null key.
+	 */
+	public Object getKey() {
+		return _key;
+	}	
+}

Propchange: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/BindParameter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=1222818&r1=1222817&r2=1222818&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Fri Dec 23 19:55:46 2011
@@ -2283,7 +2283,7 @@ public class DBDictionary
                     if (join.isCorrelated() && join.getForeignKey() != null) {
                         SQLBuffer where = new SQLBuffer(this);
                         where.append("(").append(toTraditionalJoin(join)).append(")");
-                        sel.where(where.getSQL());
+                        sel.where(where);
                     }                
                 }
             }
@@ -2343,7 +2343,7 @@ public class DBDictionary
                 if (join.getForeignKey() != null){
                     SQLBuffer where = new SQLBuffer(this);
                     where.append("(").append(toTraditionalJoin(join)).append(")");
-                    sel.where(where.getSQL());
+                    sel.where(where);
                 }                
                 break;
             }
@@ -2493,7 +2493,7 @@ public class DBDictionary
         if (join.getForeignKey() != null){
             SQLBuffer where = new SQLBuffer(this);
             where.append("(").append(toTraditionalJoin(join)).append(")");
-            sel.where(where.getSQL());
+            sel.where(where);
         }
 
         return null;

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java?rev=1222818&r1=1222817&r2=1222818&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/LogicalUnion.java Fri Dec 23 19:55:46 2011
@@ -768,14 +768,6 @@ public class LogicalUnion
             sel.where(sql, joins);
         }
 
-        public void where(String sql) {
-            sel.where(sql);
-        }
-
-        public void where(String sql, Joins joins) {
-            sel.where(sql, joins);
-        }
-
         public void having(SQLBuffer sql) {
             sel.having(sql);
         }
@@ -784,14 +776,6 @@ public class LogicalUnion
             sel.having(sql, joins);
         }
 
-        public void having(String sql) {
-            sel.having(sql);
-        }
-
-        public void having(String sql, Joins joins) {
-            sel.having(sql, joins);
-        }
-
         public void groupBy(SQLBuffer sql) {
             sel.groupBy(sql);
         }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java?rev=1222818&r1=1222817&r2=1222818&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SQLBuffer.java Fri Dec 23 19:55:46 2011
@@ -32,7 +32,6 @@ import java.util.List;
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.openjpa.jdbc.identifier.DBIdentifier;
 import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
-import org.apache.openjpa.jdbc.kernel.exps.CollectionParam;
 import org.apache.openjpa.jdbc.kernel.exps.Val;
 import org.apache.openjpa.jdbc.schema.Column;
 import org.apache.openjpa.jdbc.schema.Sequence;
@@ -53,6 +52,7 @@ import org.apache.openjpa.kernel.exps.Pa
  * 
  * @since 0.2.4
  */
+@SuppressWarnings("serial")
 public final class SQLBuffer
     implements Serializable, Cloneable {
 
@@ -60,14 +60,8 @@ public final class SQLBuffer
 
     private final DBDictionary _dict;
     private final StringBuilder _sql = new StringBuilder();
-    private List _subsels = null;
-    private List _params = null;
-    private List _cols = null;
-    
-    // Even element refers to an index of the _params list
-    // Odd element refers to the user parameter
-    private List _userIndex = null;
-    private List _userParams = null;
+    private List<Subselect> _subsels = null;
+    private List<BindParameter> _params = null;
     
     /**
      * Default constructor.
@@ -92,7 +86,7 @@ public final class SQLBuffer
     }
 
     /**
-     * Return true if the buffer is emtpy.
+     * Return true if the buffer is empty.
      */
     public boolean isEmpty() {
         return _sql.length() == 0;
@@ -102,87 +96,42 @@ public final class SQLBuffer
      * Append all SQL and parameters of the given buffer.
      */
     public SQLBuffer append(SQLBuffer buf) {
-        append(buf, _sql.length(), (_params == null) ? 0 : _params.size(),
-            true);
+        append(buf, _sql.length(), (_params == null) ? 0 : _params.size(), true);
         return this;
     }
 
     /**
      * Append all SQL and parameters of the given buffer at the given positions.
      */
-    private void append(SQLBuffer buf, int sqlIndex, int paramIndex,
-        boolean subsels) {
+    private void append(SQLBuffer buf, int sqlIndex, int paramIndex, boolean subsels) {
         if (subsels) {
             // only allow appending of buffers with subselects, not insertion
-            if (_subsels != null && !_subsels.isEmpty()
-                && sqlIndex != _sql.length())
+            if (_subsels != null && !_subsels.isEmpty() && sqlIndex != _sql.length())
                 throw new IllegalStateException();
             if (buf._subsels != null && !buf._subsels.isEmpty()) {
                 if (sqlIndex != _sql.length())
                     throw new IllegalStateException();
                 if (_subsels == null)
-                    _subsels = new ArrayList(buf._subsels.size());
+                    _subsels = new ArrayList<Subselect>(buf._subsels.size());
                 for (int i = 0; i < buf._subsels.size(); i++)
-                    _subsels.add(((Subselect) buf._subsels.get(i)).
-                        clone(sqlIndex, paramIndex));
+                    _subsels.add((buf._subsels.get(i)).clone(sqlIndex, paramIndex));
             }
         }
 
-        if (sqlIndex == _sql.length())
+        if (sqlIndex == _sql.length()) {
             _sql.append(buf._sql.toString());
-        else
+        } else {
             _sql.insert(sqlIndex, buf._sql.toString());
-
+        }
+        
         if (buf._params != null) {
             if (_params == null)
-                _params = new ArrayList();
-            if (_cols == null && buf._cols != null) {
-                _cols = new ArrayList();
-                while (_cols.size() < _params.size())
-                    _cols.add(null);
-            }
+                _params = new ArrayList<BindParameter>();
 
             if (paramIndex == _params.size()) {
                 _params.addAll(buf._params);
-                if (buf._userParams != null) {
-                    if (_userParams == null)
-                        _userParams = new ArrayList();
-                   _userParams.addAll(paramIndex, buf._userParams);
-                }
-                if (buf._userIndex != null) {
-                    if (_userIndex == null)
-                        _userIndex = new ArrayList();
-                    _userIndex.addAll(buf._userIndex);
-                }
-                if (buf._cols != null)
-                    _cols.addAll(buf._cols);
-                else if (_cols != null)
-                    while (_cols.size() < _params.size())
-                        _cols.add(null);
             } else {
                 _params.addAll(paramIndex, buf._params);
-                if ( buf._userParams != null) {
-                    if (_userParams == null)
-                        _userParams = new ArrayList();
-                    _userParams.addAll(paramIndex, buf._userParams);
-                }
-                if (buf._userIndex != null) {
-                     if (_userIndex == null)
-                         _userIndex = new ArrayList();
-                     _userIndex.addAll(buf._userIndex);
-                }
-                if (buf._cols != null)
-                    _cols.addAll(paramIndex, buf._cols);
-                else if (_cols != null)
-                    while (_cols.size() < _params.size())
-                        _cols.add(paramIndex, null);
-            }
-        }
-
-        if (_userIndex != null) {
-            // fix up user parameter index
-            for (int i = 0; i < _userIndex.size(); i+=2) {
-                _userIndex.set(i, _userParams.indexOf(_userIndex.get(i+1)));
             }
         }
     }
@@ -241,7 +190,7 @@ public final class SQLBuffer
         _sql.append(")");
 
         if (_subsels == null)
-            _subsels = new ArrayList(2);
+            _subsels = new ArrayList<Subselect>(2);
         _subsels.add(sub);
         return this;
     }
@@ -267,7 +216,8 @@ public final class SQLBuffer
      * Append a parameter value.
      */
     public SQLBuffer appendValue(Object o) {
-        return appendValue(o, null);
+    	_sql.append(o == null ? "NULL" : o.toString());
+        return this;
     }
     
     /**
@@ -293,34 +243,11 @@ public final class SQLBuffer
         else {
             _sql.append(PARAMETER_TOKEN);
 
-            // initialize param and col lists; we hold off on col list until
-            // we get the first non-null col
             if (_params == null)
-                _params = new ArrayList();
-            if (_userParams == null)
-                _userParams = new ArrayList();
-            if (col != null && _cols == null) {
-                _cols = new ArrayList();
-                while (_cols.size() < _params.size())
-                    _cols.add(null);
-            }
-
-            _params.add(o);
-            if (userParam != null) {
-                Object param = userParam;
-                if (userParam instanceof CollectionParam)
-                    param = ((CollectionParam) userParam).clone();
-                _userParams.add(param);
-                if (_userIndex == null)
-                    _userIndex = new ArrayList();
-                int index = _params.size()-1;
-                _userIndex.add(index);
-                _userIndex.add(param);
-            }
-            else
-                _userParams.add(o);
-            if (_cols != null)
-                _cols.add(col);
+                _params = new ArrayList<BindParameter>();
+            BindParameter param = new BindParameter(userParam == null ? col : userParam, 
+            		userParam != null, col, o);
+            _params.add(param);
         }
         return this;
     }
@@ -328,8 +255,9 @@ public final class SQLBuffer
     /**
      * Return the list of parameter values.
      */
-    public List getParameters() {
-        return (_params == null) ? Collections.EMPTY_LIST : _params;
+    public List<BindParameter> getParameters() {
+    	if (_params == null) return Collections.emptyList();
+        return _params;
     }
     
     /**
@@ -340,10 +268,18 @@ public final class SQLBuffer
      * This structure is preferred over a normal map because a user parameter 
      * may occur more than one in the parameters. 
      */
-    public List getUserParameters() {
-        if (_userIndex == null)
-            return Collections.EMPTY_LIST;
-        return _userIndex;
+    public List<Object> getUserParameters() {
+        if (_params == null)
+            return Collections.emptyList();
+        List<Object> userParam = new ArrayList<Object>();
+        for (int i = 0; i < _params.size(); i++) {
+        	BindParameter param = _params.get(i);
+        	if (param.isUser()) {
+        		userParam.add(i);
+        		userParam.add(param.getKey());
+        	}
+        }
+        return userParam;
     }
 
     /**
@@ -366,14 +302,14 @@ public final class SQLBuffer
             return sql;
 
         StringBuilder buf = new StringBuilder();
-        Iterator pi = _params.iterator();
+        Iterator<BindParameter> pi = _params.iterator();
         for (int i = 0; i < sql.length(); i++) {
             if (sql.charAt(i) != '?') {
                 buf.append(sql.charAt(i));
                 continue;
             }
 
-            Object param = pi.hasNext() ? pi.next() : null;
+            Object param = pi.hasNext() ? pi.next().getValue() : null;
             if (param == null)
                 buf.append("NULL");
             else if (param instanceof Number || param instanceof Boolean)
@@ -430,7 +366,7 @@ public final class SQLBuffer
     }
 
     /**
-     * Create and populate the parameters of a prepred statement using the
+     * Create and populate the parameters of a prepared statement using the
      * SQL in this buffer and the given fetch configuration.
      */
     public PreparedStatement prepareStatement(Connection conn,
@@ -538,10 +474,9 @@ public final class SQLBuffer
         if (_params == null)
             return;
 
-        Column col;
         for (int i = 0; i < _params.size(); i++) {
-            col = (_cols == null) ? null : (Column) _cols.get(i);
-            _dict.setUnknown(ps, i + 1, _params.get(i), col);
+        	BindParameter param = _params.get(i);
+            _dict.setUnknown(ps, i + 1, param.getValue(), param.getColumn());
         }
     }
 
@@ -618,11 +553,21 @@ public final class SQLBuffer
         }
     }
     
-    public void setParameters(List params) {
-        _params = params;
+    /**
+     * Sets the binding parameters, clearing all existing parameters.
+     * 
+     * @param params a non-null list of parameters.
+     */
+    public void setParameters(List<?> params) {
+    	if (params == null) {
+    		throw new IllegalArgumentException("Can not set null parameter");
+    	}
+    	_params = new ArrayList<BindParameter>();
+    	int i = 0;
+    	for (Object p : params) {
+    		BindParameter param = new BindParameter(i, false, null, p);
+    		_params.add(param);
+    	}
     }
     
-    public List getColumns() {
-        return _cols;
-    }
 }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java?rev=1222818&r1=1222817&r2=1222818&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/Select.java Fri Dec 23 19:55:46 2011
@@ -546,12 +546,12 @@ public interface Select
     /**
      * Add the given where conditions.
      */
-    public void where(String sql);
+//    public void where(String sql);
 
     /**
      * Add the given where conditions.
      */
-    public void where(String sql, Joins joins);
+//    public void where(String sql, Joins joins);
 
     /**
      * Add the given having conditions.
@@ -566,12 +566,12 @@ public interface Select
     /**
      * Add the given having conditions.
      */
-    public void having(String sql);
+//    public void having(String sql);
 
     /**
      * Add the given having conditions.
      */
-    public void having(String sql, Joins joins);
+//    public void having(String sql, Joins joins);
 
     /**
      * Group by the given column.
@@ -606,12 +606,12 @@ public interface Select
     /**
      * Add a GROUP BY clause.
      */
-    public void groupBy(String sql);
+//    public void groupBy(String sql);
 
     /**
      * Add a GROUP BY clause.
      */
-    public void groupBy(String sql, Joins joins);
+//    public void groupBy(String sql, Joins joins);
 
     /**
      * Group by the columns of the given mapping, possibly including subclasses.

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?rev=1222818&r1=1222817&r2=1222818&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java Fri Dec 23 19:55:46 2011
@@ -1394,8 +1394,7 @@ public class SelectImpl
             } else {
                 // must be app identity; use pk index to get correct pk value
                 join = mapping.assertJoinable(toCols[i]);
-                val = pks[mapping.getField(join.getFieldIndex()).
-                    getPrimaryKeyIndex()];
+                val = pks[mapping.getField(join.getFieldIndex()).getPrimaryKeyIndex()];
                 val = join.getJoinValue(val, toCols[i], store);
             }
 
@@ -1447,7 +1446,7 @@ public class SelectImpl
 
     public void where(Joins joins) {
         if (joins != null)
-            where((String) null, joins);
+            where((SQLBuffer) null, joins);
     }
 
     public void where(SQLBuffer sql) {
@@ -1473,28 +1472,6 @@ public class SelectImpl
         _where.append(sql);
     }
 
-    public void where(String sql) {
-        where(sql, (Joins) null);
-    }
-
-    public void where(String sql, Joins joins) {
-        where(sql, getJoins(joins, true));
-    }
-
-    /**
-     * Add the given condition to the WHERE clause.
-     */
-    private void where(String sql, PathJoins pj) {
-        // no need to use joins...
-        if (StringUtils.isEmpty(sql))
-            return;
-
-        if (_where == null)
-            _where = new SQLBuffer(_dict);
-        else if (!_where.isEmpty())
-            _where.append(" AND ");
-        _where.append(sql);
-    }
 
     public void having(SQLBuffer sql) {
         having(sql, (Joins) null);
@@ -1519,29 +1496,6 @@ public class SelectImpl
         _having.append(sql);
     }
 
-    public void having(String sql) {
-        having(sql, (Joins) null);
-    }
-
-    public void having(String sql, Joins joins) {
-        having(sql, getJoins(joins, true));
-    }
-
-    /**
-     * Add the given condition to the HAVING clause.
-     */
-    private void having(String sql, PathJoins pj) {
-        // no need to use joins...
-        if (StringUtils.isEmpty(sql))
-            return;
-
-        if (_having == null)
-            _having = new SQLBuffer(_dict);
-        else if (!_having.isEmpty())
-            _having.append(" AND ");
-        _having.append(sql);
-    }
-
     public void groupBy(SQLBuffer sql) {
         groupBy(sql, (Joins) null);
     }
@@ -2051,10 +2005,6 @@ public class SelectImpl
 
         // not found; create alias
         i = aliasSize(false, null);
-//        System.out.println("GetTableIndex\t"+
-//                ((_parent != null) ? "Sub" :"") +
-//                " created alias: "+
-//                i.intValue()+ " "+ key);
         recordTableAlias(table, key, i);
         return i.intValue();
     }
@@ -2113,10 +2063,6 @@ public class SelectImpl
 
     private int createAlias(Table table, Object key) {
         Integer i = ctx().nextAlias();
-//        System.out.println("\t"+
-//                ((_parent != null) ? "Sub" :"") +
-//                "Query created alias: "+ 
-//                i.intValue()+ " "+ key);
         recordTableAlias(table, key, i);
         return i.intValue();
     }