Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 78393 invoked from network); 7 Aug 2004 20:00:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Aug 2004 20:00:29 -0000 Received: (qmail 35420 invoked by uid 500); 7 Aug 2004 20:00:29 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 35292 invoked by uid 500); 7 Aug 2004 20:00:28 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 35277 invoked by uid 500); 7 Aug 2004 20:00:28 -0000 Received: (qmail 35271 invoked by uid 99); 7 Aug 2004 20:00:28 -0000 X-ASF-Spam-Status: No, hits=-2.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Sat, 07 Aug 2004 13:00:27 -0700 Received: (qmail 78382 invoked by uid 1513); 7 Aug 2004 20:00:27 -0000 Date: 7 Aug 2004 20:00:27 -0000 Message-ID: <20040807200027.78381.qmail@minotaur.apache.org> From: brj@apache.org To: db-ojb-cvs@apache.org Subject: cvs commit: db-ojb/src/test/org/apache/ojb/broker MultipleTableExtentAwareQueryTest.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N brj 2004/08/07 13:00:26 Modified: src/schema ojbtest-schema.xml src/java/org/apache/ojb/broker/util BrokerHelper.java src/test/org/apache/ojb repository_junit.xml src/test/org/apache/ojb/broker MultipleTableExtentAwareQueryTest.java Log: - testcase by Charles Anthony - improved BrokerHelper, do not use IN for a single concreteClass Revision Changes Path 1.85 +5 -0 db-ojb/src/schema/ojbtest-schema.xml Index: ojbtest-schema.xml =================================================================== RCS file: /home/cvs/db-ojb/src/schema/ojbtest-schema.xml,v retrieving revision 1.84 retrieving revision 1.85 diff -u -r1.84 -r1.85 --- ojbtest-schema.xml 27 Jul 2004 23:38:49 -0000 1.84 +++ ojbtest-schema.xml 7 Aug 2004 20:00:26 -0000 1.85 @@ -324,21 +324,25 @@ +
+
+
+
@@ -1448,5 +1452,6 @@ + 1.60 +31 -9 db-ojb/src/java/org/apache/ojb/broker/util/BrokerHelper.java Index: BrokerHelper.java =================================================================== RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/BrokerHelper.java,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- BrokerHelper.java 24 Jul 2004 19:26:40 -0000 1.59 +++ BrokerHelper.java 7 Aug 2004 20:00:26 -0000 1.60 @@ -837,10 +837,10 @@ } /** - * Add a Criteria for Concrete Class to the copied Query + * Add a Criteria for Concrete Class to the copied Query. * @param aQuery * @param aCld - * @return + * @return a copy of the Query */ public Query setConcreteClassCriteria(QueryByCriteria aQuery, ClassDescriptor aCld) { @@ -858,19 +858,29 @@ } /** - * Add a Criteria for Concrete Classes to the copied Query + * Add a Criteria for Concrete Classes to the copied Query.
+ * use addEqualTo() if the List contains only 1 element, addIn() if it contains more elements * @param aQuery * @param concreteClasses - * @return + * @return a copy of the Query */ - public Query setConcreteClassCriteria(QueryByCriteria aQuery, Collection concreteClasses) + public Query setConcreteClassCriteria(QueryByCriteria aQuery, List concreteClasses) { Query result = aQuery; if (concreteClasses != null) { QueryByCriteria copyQuery = QueryFactory.copyQuery(aQuery); - copyQuery.getCriteria().addIn(ClassDescriptor.OJB_CONCRETE_CLASS, concreteClasses); + + if (concreteClasses.size() > 1) + { + copyQuery.getCriteria().addIn(ClassDescriptor.OJB_CONCRETE_CLASS, concreteClasses); + } + else + { + copyQuery.getCriteria().addEqualTo(ClassDescriptor.OJB_CONCRETE_CLASS, concreteClasses.get(0)); + } + result = copyQuery; } @@ -907,12 +917,24 @@ } /** - * Holder for ClassDescriptor and it's concreteClasses + * Holder for ClassDescriptor and it's concreteClasses (a List of Strings) */ public static class CldInfo { + /** + * the ClassDescriptor + */ public ClassDescriptor cld; - public Collection concreteClasses; + + /** + * a List of Strings + */ + public List concreteClasses; + + public String toString() + { + return cld.getFullTableName() + " " + concreteClasses; + } } /** 1.119 +70 -1 db-ojb/src/test/org/apache/ojb/repository_junit.xml Index: repository_junit.xml =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit.xml,v retrieving revision 1.118 retrieving revision 1.119 diff -u -r1.118 -r1.119 --- repository_junit.xml 4 Aug 2004 21:05:19 -0000 1.118 +++ repository_junit.xml 7 Aug 2004 20:00:26 -0000 1.119 @@ -2579,6 +2579,12 @@ column="NAME" jdbc-type="VARCHAR" /> + + + + + + + + + + + + + + + + + + + 1.4 +18 -4 db-ojb/src/test/org/apache/ojb/broker/MultipleTableExtentAwareQueryTest.java Index: MultipleTableExtentAwareQueryTest.java =================================================================== RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/MultipleTableExtentAwareQueryTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MultipleTableExtentAwareQueryTest.java 27 Jul 2004 23:38:49 -0000 1.3 +++ MultipleTableExtentAwareQueryTest.java 7 Aug 2004 20:00:26 -0000 1.4 @@ -54,8 +54,14 @@ a.setName(name); ExtentB b = new ExtentB(); b.setName(name); + ExtentE e = new ExtentE(); + e.setName(name); + ExtentF f = new ExtentF(); + f.setName(name); broker.store(a); broker.store(b); + broker.store(e); + broker.store(f); } broker.commitTransaction(); @@ -64,10 +70,10 @@ QueryByCriteria query = QueryFactory.newQuery(BaseClass.class, crit); Collection result = broker.getCollectionByQuery(query); assertNotNull(result); - assertEquals("Expect all objects extending 'BaseClass'", 2*objCount, result.size()); + assertEquals("Expect all objects extending 'BaseClass'", 4*objCount, result.size()); int count = broker.getCount(query); - assertEquals("Expect all objects extending 'BaseClass'", 2*objCount, count); + assertEquals("Expect all objects extending 'BaseClass'", 4*objCount, count); } public void testQueryForExtentsOfAbstractClass() @@ -199,7 +205,6 @@ QueryByCriteria queryC = QueryFactory.newQuery(ExtentC.class, crit); QueryByCriteria queryD = QueryFactory.newQuery(ExtentD.class, crit); - Collection result = broker.getCollectionByQuery(queryBaseClassIF); assertNotNull(result); assertEquals("Wrong number of objects", 6, result.size()); @@ -308,6 +313,7 @@ { } + public static class ExtentC extends ExtentB { } @@ -327,6 +333,13 @@ } } + public static class ExtentE extends ExtentB + { + } + + public static class ExtentF extends ExtentB + { + } public static interface BaseClassIF extends Serializable { public int getObjId(); @@ -339,6 +352,7 @@ { private int objId; private String name; + private String ojbConcreteClass = this.getClass().getName(); public int getObjId() { --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org