Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 7335 invoked from network); 24 Jul 2004 19:26:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 24 Jul 2004 19:26:43 -0000 Received: (qmail 13446 invoked by uid 500); 24 Jul 2004 19:26:42 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 13404 invoked by uid 500); 24 Jul 2004 19:26:42 -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 13391 invoked by uid 500); 24 Jul 2004 19:26:41 -0000 Received: (qmail 13388 invoked by uid 99); 24 Jul 2004 19:26:41 -0000 X-ASF-Spam-Status: No, hits=0.5 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, 24 Jul 2004 12:26:41 -0700 Received: (qmail 7325 invoked by uid 1513); 24 Jul 2004 19:26:41 -0000 Date: 24 Jul 2004 19:26:41 -0000 Message-ID: <20040724192641.7323.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 QueryTest.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N brj 2004/07/24 12:26:40 Modified: src/java/org/apache/ojb/broker/accesslayer/sql SqlQueryStatement.java SqlSelectStatement.java src/java/org/apache/ojb/broker/util BrokerHelper.java . release-notes.txt src/test/org/apache/ojb/broker QueryTest.java Log: - add orderBy-columns to select-clause (because of sapdb) - use orderBy-columns of query as joinAttributes of count-query Revision Changes Path 1.78 +33 -2 db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java Index: SqlQueryStatement.java =================================================================== RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java,v retrieving revision 1.77 retrieving revision 1.78 diff -u -r1.77 -r1.78 --- SqlQueryStatement.java 21 Jul 2004 09:19:20 -0000 1.77 +++ SqlQueryStatement.java 24 Jul 2004 19:26:40 -0000 1.78 @@ -488,7 +488,38 @@ } } } - + + /** + * Builds the Join for columns if they are not found among the existingColumns. + * These columns are added to the statement using a column-alias "ojb_col_x", + * x being the number of existing columns + * @param columns the list of columns represented by Criteria.Field to ensure + * @param existingColumns the list of column names (String) that are already appended + * @param buf the statement + */ + protected void ensureColumns(List columns, List existingColumns, StringBuffer buf) + { + if (columns == null || columns.isEmpty()) + { + return; + } + + Iterator iter = columns.iterator(); + int ojb_col = existingColumns.size(); + + while (iter.hasNext()) + { + FieldHelper cf = (FieldHelper) iter.next(); + if (!existingColumns.contains(cf.name)) + { + buf.append(","); + appendColName(cf.name, "ojb_col_" + ojb_col, false, null, buf); + ojb_col++; + } + } + } + + /** * appends a WHERE-clause to the Statement * @param where 1.25 +2 -2 db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java Index: SqlSelectStatement.java =================================================================== RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- SqlSelectStatement.java 21 Jul 2004 09:19:20 -0000 1.24 +++ SqlSelectStatement.java 24 Jul 2004 19:26:40 -0000 1.25 @@ -217,7 +217,7 @@ ensureColumns(groupByFields, columnList); orderByFields = query.getOrderBy(); - ensureColumns(orderByFields, columnList); + ensureColumns(orderByFields, columnList, stmt); /** * treeder: going to map superclass tables here, 1.59 +14 -1 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.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- BrokerHelper.java 13 Jul 2004 11:37:57 -0000 1.58 +++ BrokerHelper.java 24 Jul 2004 19:26:40 -0000 1.59 @@ -598,6 +598,19 @@ countQuery.setPathOuterJoin(path); } } + + //BRJ: add orderBy Columns asJoinAttributes + List orderBy = aQuery.getOrderBy(); + if (orderBy != null && !orderBy.isEmpty()) + { + String[] joinAttributes = new String[orderBy.size()]; + for (int i=0; i