Return-Path: X-Original-To: apmail-db-torque-dev-archive@www.apache.org Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6B4A9E138 for ; Tue, 19 Feb 2013 08:40:21 +0000 (UTC) Received: (qmail 32606 invoked by uid 500); 19 Feb 2013 08:40:21 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 32580 invoked by uid 500); 19 Feb 2013 08:40:20 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 32555 invoked by uid 500); 19 Feb 2013 08:40:20 -0000 Received: (qmail 32552 invoked by uid 99); 19 Feb 2013 08:40:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Feb 2013 08:40:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Feb 2013 08:40:16 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 91F462388900; Tue, 19 Feb 2013 08:39:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1447624 - /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java Date: Tue, 19 Feb 2013 08:39:56 -0000 To: torque-commits@db.apache.org From: tfischer@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130219083956.91F462388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tfischer Date: Tue Feb 19 08:39:56 2013 New Revision: 1447624 URL: http://svn.apache.org/r1447624 Log: TORQUE-268 Copy constructor for Criteria Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java?rev=1447624&r1=1447623&r2=1447624&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java Tue Feb 19 08:39:56 2013 @@ -137,23 +137,22 @@ public class Criteria private boolean singleRecord = false; /** List of modifiers like DISTICT. */ - private final UniqueList selectModifiers = new UniqueList(); + private final UniqueList selectModifiers; /** List of all columns to select. */ - private final UniqueColumnList selectColumns = new UniqueColumnList(); + private final UniqueColumnList selectColumns; /** All "order by" clauses, containing the order ASC or DESC. */ - private final UniqueList orderByColumns = new UniqueList(); + private final UniqueList orderByColumns; /** The names of columns to add to a groupBy clause */ - private final UniqueColumnList groupByColumns = new UniqueColumnList(); + private final UniqueColumnList groupByColumns; /** * All "from" clauses. Empty if the from clause should be computed * automatically. */ - private final UniqueList fromElements - = new UniqueList(); + private final UniqueList fromElements; /** The having clause in a query. */ private Criterion having = null; @@ -168,11 +167,10 @@ public class Criteria * Maps column alias names to the real column names. * The key of the map is the alias and the value is the real column. */ - private final Map asColumns - = new LinkedHashMap(); + private final Map asColumns; /** Contains all joins. */ - private final List joins = new ArrayList(); + private final List joins; /** The name of the database in which this criteria should execute. */ private String dbName; @@ -191,31 +189,72 @@ public class Criteria * and the value is either the real name of the table * or a corresponding subselect. */ - private final Map aliases = new HashMap(); + private final Map aliases; /** The JDBC statement fetch size, if any. */ private Integer fetchSize; /** - * Creates a new instance with the default capacity. + * Constructor. */ public Criteria() { - // empty + selectModifiers = new UniqueList(); + selectColumns = new UniqueColumnList(); + orderByColumns = new UniqueList(); + groupByColumns = new UniqueColumnList(); + fromElements = new UniqueList(); + asColumns = new LinkedHashMap(); + joins = new ArrayList(); + aliases = new HashMap(); } /** - * Creates a new instance with the default capacity which corresponds to - * the specified database. + * Constructor with the database name as parameter.. * * @param dbName The database name. */ public Criteria(String dbName) { + this(); this.dbName = dbName; } /** + * Copy-constructor. + * The copy is deep insofar as all contained lists are copied, + * however the elements contained in the list are not copied. + * + * @param toCopy the criteria to copy. + */ + public Criteria(Criteria toCopy) + { + ignoreCase = toCopy.ignoreCase; + singleRecord = toCopy.singleRecord; + selectModifiers = new UniqueList(toCopy.selectModifiers); + selectColumns = new UniqueColumnList(toCopy.selectColumns); + orderByColumns = new UniqueList(toCopy.orderByColumns); + groupByColumns = new UniqueColumnList(toCopy.groupByColumns); + fromElements = new UniqueList(toCopy.fromElements); + if (toCopy.having != null) + { + having = new Criterion(toCopy.having); + } + forUpdate = toCopy.forUpdate; + if (toCopy.topLevelCriterion != null) + { + topLevelCriterion = new Criterion(toCopy.topLevelCriterion); + } + asColumns = new HashMap(toCopy.asColumns); + joins = new ArrayList(toCopy.joins); + dbName = toCopy.dbName; + limit = toCopy.limit; + offset = toCopy.offset; + aliases = new HashMap(toCopy.aliases); + fetchSize = toCopy.fetchSize; + } + + /** * Add an AS clause to the select columns. Usage: *

* @@ -982,7 +1021,9 @@ public class Criteria } /** - * Returns a cloned object. + * Returns a shallow copy of this object. + * + * @return the cloned criteria. */ @Override public Object clone() --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org