You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2012/11/13 21:36:06 UTC
svn commit: r1408945 - in /db/torque/torque4/trunk/torque-runtime/src:
main/java/org/apache/torque/criteria/Criterion.java
test/java/org/apache/torque/criteria/CriterionTest.java
Author: tfischer
Date: Tue Nov 13 20:36:05 2012
New Revision: 1408945
URL: http://svn.apache.org/viewvc?rev=1408945&view=rev
Log:
TORQUE-243 Also use copies of Criterions for Criterion.and and Criterion.or
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java
db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java
Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java?rev=1408945&r1=1408944&r2=1408945&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java Tue Nov 13 20:36:05 2012
@@ -398,14 +398,14 @@ public class Criterion implements Serial
}
if (isComposite() && this.conjunction.equals(conjunction))
{
- parts.add(criterion);
+ parts.add(new Criterion(criterion));
}
else
{
Criterion copy = new Criterion(this);
parts = new ArrayList<Criterion>();
parts.add(copy);
- parts.add(criterion);
+ parts.add(new Criterion(criterion));
this.conjunction = conjunction;
this.rValue = null;
this.comparison = null;
Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java?rev=1408945&r1=1408944&r2=1408945&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java Tue Nov 13 20:36:05 2012
@@ -72,4 +72,64 @@ public class CriterionTest extends BaseT
+ "AND myTable.myColumn3>=3)",
criterion.toString());
}
+
+ /**
+ * Tests that a criterion is copied when being anded to a top level
+ * criterion.
+ * checks TORQUE-243.
+ */
+ public void testCriterionAndedToTopLevelCriterionGetsCopied()
+ {
+ Criterion criterion = new Criterion(stringColumnMap, "abc");
+ Criterion andedCriterion = new Criterion(stringColumnMap, "def");
+ criterion.and(andedCriterion);
+ assertNotSame(criterion.getParts().get(0), andedCriterion);
+ assertNotSame(criterion.getParts().get(1), andedCriterion);
+ }
+
+ /**
+ * Tests that a criterion is copied when being ored to a top level
+ * criterion.
+ * checks TORQUE-243.
+ */
+ public void testCriterionOredToTopLevelCriterionGetsCopied()
+ {
+ Criterion criterion = new Criterion(stringColumnMap, "abc");
+ Criterion oredCriterion = new Criterion(stringColumnMap, "def");
+ criterion.or(oredCriterion);
+ assertNotSame(criterion.getParts().get(0), oredCriterion);
+ assertNotSame(criterion.getParts().get(1), oredCriterion);
+ }
+
+ /**
+ * Tests that a criterion is copied when being anded to a top level
+ * criterion.
+ * checks TORQUE-243.
+ */
+ public void testCriterionAndedToCriterionGetsCopied()
+ {
+ Criterion criterion = new Criterion(stringColumnMap, "abc");
+ criterion.and(new Criterion(stringColumnMap, "xyz"));
+ Criterion andedCriterion = new Criterion(stringColumnMap, "def");
+ criterion.and(andedCriterion);
+ assertNotSame(criterion.getParts().get(0), andedCriterion);
+ assertNotSame(criterion.getParts().get(1), andedCriterion);
+ assertNotSame(criterion.getParts().get(2), andedCriterion);
+ }
+
+ /**
+ * Tests that a criterion is copied when being ored to a top level
+ * criterion.
+ * checks TORQUE-243.
+ */
+ public void testCriterionOredToCriterionGetsCopied()
+ {
+ Criterion criterion = new Criterion(stringColumnMap, "abc");
+ criterion.or(new Criterion(stringColumnMap, "xyz"));
+ Criterion oredCriterion = new Criterion(stringColumnMap, "def");
+ criterion.or(oredCriterion);
+ assertNotSame(criterion.getParts().get(0), oredCriterion);
+ assertNotSame(criterion.getParts().get(1), oredCriterion);
+ assertNotSame(criterion.getParts().get(2), oredCriterion);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org