db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker QueryTest.java
Date Thu, 03 Jun 2004 18:18:17 GMT
brj         2004/06/03 11:18:17

  Modified:    src/test/org/apache/ojb/broker QueryTest.java
  Log:
  additional testcase for report-queries using extents
  
  Revision  Changes    Path
  1.59      +54 -1     db-ojb/src/test/org/apache/ojb/broker/QueryTest.java
  
  Index: QueryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/QueryTest.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- QueryTest.java	2 Jun 2004 11:48:39 -0000	1.58
  +++ QueryTest.java	3 Jun 2004 18:18:17 -0000	1.59
  @@ -681,8 +681,10 @@
   
       /**
   	 * ReportQuery returning rows with summed stock and price per article group
  +	 * The selected columns point to a class having extents.<br>
  +	 * The query produces a wrong sql, selecting only rows of the top-class
   	 */
  -    public void testReportQueryGroupBy()
  +    public void testReportQueryGroupByExtents2()
       {
           Criteria crit = new Criteria();
           Collection results = new Vector();
  @@ -691,6 +693,14 @@
           q.addGroupBy("groupName");
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +        
  +//        SELECT A0.KategorieName,sum(A1.Lagerbestand),sum(A1.Einzelpreis)
  +//        FROM Kategorien A0
  +//        LEFT OUTER JOIN artikel A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr
  +//        LEFT OUTER JOIN books A1E2 ON A0.Kategorie_Nr=A1E2.Kategorie_Nr
  +//        LEFT OUTER JOIN cds A1E1 ON A0.Kategorie_Nr=A1E1.Kategorie_Nr
  +//        GROUP BY A0.KategorieName
  +        
           assertNotNull(iter);
           while (iter.hasNext())
           {
  @@ -703,6 +713,49 @@
           // assertEquals(results.size(), count);   // FAILS !
       }
   
  +    /**
  +	 * ReportQuery returning rows with summed stock and price per article group
  +	 * The selected class has the extents.<br>
  +	 * The query returns summed values for each row, so there may be multiple rows
  +	 * for one productgroup because one query for each extent is executed.
  +	 */
  +    public void testReportQueryGroupByExtents1()
  +    {
  +        Criteria crit = new Criteria();
  +        Collection results = new Vector();
  +        ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class, crit);
  +        q.setAttributes(new String[] { "productGroup.groupName", "sum(stock)", "sum(price)"
});
  +        q.addGroupBy("productGroup.groupName");
  +
  +        Iterator iter = broker.getReportQueryIteratorByQuery(q);
  +        
  +//        SELECT  A1.KategorieName,sum(A0.Lagerbestand),sum(A0.Einzelpreis) 
  +//        FROM artikel A0 
  +//        INNER JOIN Kategorien A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr
  +//        GROUP BY A1.KategorieName
  +//
  +//        SELECT  A1.KategorieName,sum(A0.Lagerbestand),sum(A0.Einzelpreis) 
  +//        FROM cds A0 
  +//        INNER JOIN Kategorien A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr
  +//        GROUP BY A1.KategorieName
  +//
  +//        SELECT  A1.KategorieName,sum(A0.Lagerbestand),sum(A0.Einzelpreis) 
  +//        FROM books A0 
  +//        INNER JOIN Kategorien A1 ON A0.Kategorie_Nr=A1.Kategorie_Nr
  +//        GROUP BY A1.KategorieName
  +
  +        assertNotNull(iter);
  +        while (iter.hasNext())
  +        {
  +            results.add(iter.next());
  +        }
  +        assertTrue(results.size() > 0);
  +
  +        // compare with count
  +        int count = broker.getCount(q);
  +        // assertEquals(results.size(), count);   // FAILS !
  +    }
  +    
       /**
   	 * Read a CD and then read the ProductGroup for the CD
   	 */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message