Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java?rev=1484252&r1=1484251&r2=1484252&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java Sun May 19 09:58:00 2013 @@ -35,6 +35,7 @@ import org.apache.torque.Column; import org.apache.torque.ColumnImpl; import org.apache.torque.Torque; import org.apache.torque.TorqueException; +import org.apache.torque.criteria.Criteria; import org.apache.torque.criteria.SqlEnum; import org.apache.torque.map.TableMap; import org.apache.torque.om.mapper.IntegerMapper; @@ -56,30 +57,8 @@ public class CountHelper * @param c Criteria to get the count for. * @return number of rows matching the query provided * @throws TorqueException if the query could not be executed - * - * @deprecated use org.apache.torque.criteria.Criteria instead of - * org.apache.torque.util.Criteria. This method will be removed - * in Torque 4.1. - */ - @Deprecated - public int count(Criteria c) throws TorqueException - { - return count(c, null, "*", null); - } - - /** - * The COUNT function returns the number of rows in a query. - * Does not use a connection, hardcode the column to "*" and - * set the distinct qualifier to false. - * Only use this function if you have added additional constraints to - * the criteria, otherwise Torque does not know which table it should - * count the datasets in. - * - * @param c Criteria to get the count for. - * @return number of rows matching the query provided - * @throws TorqueException if the query could not be executed */ - public int count(org.apache.torque.criteria.Criteria c) + public int count(final Criteria c) throws TorqueException { return count(c, null, "*", null); @@ -96,30 +75,8 @@ public class CountHelper * @param conn Connection to use * @return number of rows matching the query provided * @throws TorqueException if the query could not be executed - * - * @deprecated use org.apache.toraue.criteria.Criteria instead of - * org.apache.toraue.util.Criteria. This method will be removed - * in Torque 4.1. - */ - @Deprecated - public int count(Criteria c, Connection conn) throws TorqueException - { - return count(c, conn, "*", null); - } - - /** - * The COUNT function returns the number of rows in a query. - * Hard code the distinct parameter to false and set the column to "*". - * Only use this function if you have added additional constraints to - * the criteria, otherwise Torque does not know which table it should - * count the datasets in. - * - * @param c Criteria to get the count for. - * @param conn Connection to use - * @return number of rows matching the query provided - * @throws TorqueException if the query could not be executed */ - public int count(org.apache.torque.criteria.Criteria c, Connection conn) + public int count(final Criteria c, final Connection conn) throws TorqueException { return count(c, conn, "*", null); @@ -133,28 +90,8 @@ public class CountHelper * use the primary key here. * @return number of rows matching the query provided * @throws TorqueException if the query could not be executed - * - * @deprecated use org.apache.toraue.criteria.Criteria instead of - * org.apache.toraue.util.Criteria. This method will be removed - * in Torque 4.1. */ - @Deprecated - public int count(Criteria c, String columnName) - throws TorqueException - { - return count(c, null, columnName, null); - } - - /** - * Returns the number of rows in a query. - * - * @param c Criteria to get the count for. - * @param columnName Name of database Column which is counted. Preferably, - * use the primary key here. - * @return number of rows matching the query provided - * @throws TorqueException if the query could not be executed - */ - public int count(org.apache.torque.criteria.Criteria c, String columnName) + public int count(final Criteria c, final String columnName) throws TorqueException { return count(c, null, columnName, null); @@ -168,28 +105,8 @@ public class CountHelper * use the primary key here. * @return number of rows matching the query provided * @throws TorqueException if the query could not be executed - * - * @deprecated use org.apache.toraue.criteria.Criteria instead of - * org.apache.toraue.util.Criteria. This method will be removed - * in Torque 4.1. */ - @Deprecated - public int count(Criteria c, Column column) - throws TorqueException - { - return count(c, null, column.getSqlExpression(), null); - } - - /** - * Returns the number of rows in a query. - * - * @param c Criteria to get the count for. - * @param column the database Column which is counted. Preferably, - * use the primary key here. - * @return number of rows matching the query provided - * @throws TorqueException if the query could not be executed - */ - public int count(org.apache.torque.criteria.Criteria c, Column column) + public int count(final Criteria c, final Column column) throws TorqueException { return count(c, column.getSqlExpression()); @@ -204,32 +121,11 @@ public class CountHelper * use the primary key here. * @return number of rows matching the query provided * @throws TorqueException if the query could not be executed - * - * @deprecated use org.apache.toraue.criteria.Criteria instead of - * org.apache.toraue.util.Criteria. This method will be removed - * in Torque 4.1. - */ - @Deprecated - public int count(Criteria c, Connection conn, Column column) - throws TorqueException - { - return count(c, conn, column.getSqlExpression(), null); - } - - /** - * Returns the number of rows in a query. - * - * @param c Criteria to get the count for. - * @param conn Connection to use - * @param column The database Column which is counted. Preferably, - * use the primary key here. - * @return number of rows matching the query provided - * @throws TorqueException if the query could not be executed */ public int count( - org.apache.torque.criteria.Criteria c, - Connection conn, - Column column) + final Criteria c, + final Connection conn, + final Column column) throws TorqueException { return count(c, conn, column.getSqlExpression(), null); @@ -244,11 +140,11 @@ public class CountHelper * * @throws TorqueException if the query could not be executed */ - public int count(TableMap tableMap) + public int count(final TableMap tableMap) throws TorqueException { return count( - new org.apache.torque.criteria.Criteria(), + new Criteria(), null, "*", tableMap); @@ -264,11 +160,11 @@ public class CountHelper * * @throws TorqueException if the query could not be executed */ - public int count(TableMap tableMap, Connection conn) + public int count(final TableMap tableMap, final Connection conn) throws TorqueException { return count( - new org.apache.torque.criteria.Criteria(), + new Criteria(), conn, "*", tableMap); @@ -287,72 +183,12 @@ public class CountHelper * @return number of rows matching the query provided. * * @throws TorqueException if the query could not be executed. - * - * @deprecated use org.apache.toraue.criteria.Criteria instead of - * org.apache.toraue.util.Criteria. This method will be removed - * in Torque 4.1. - */ - @Deprecated - public int count( - Criteria c, - Connection conn, - String columnName, - TableMap tableMap) - throws TorqueException - { - /* Clear the select columns. */ - c.getSelectColumns().clear(); - c.getOrderByColumns().clear(); - c.getGroupByColumns().clear(); - - UniqueList<String> criteriaSelectModifiers - = c.getSelectModifiers(); - - boolean distinct = false; - if (criteriaSelectModifiers != null - && criteriaSelectModifiers.size() > 0 - && criteriaSelectModifiers.contains(SqlEnum.DISTINCT.toString())) - { - criteriaSelectModifiers.remove(SqlEnum.DISTINCT.toString()); - distinct = true; - } - - c.addSelectColumn(new Count(new ColumnImpl(columnName), distinct)); - - String databaseName = (c.getDbName() == null) - ? Torque.getDefaultDB() - : c.getDbName(); - - BasePeerImpl<Integer> peer = new BasePeerImpl<Integer>( - new IntegerMapper(), - tableMap, databaseName); - - List<Integer> result = (conn == null) - ? peer.doSelect(c) - : peer.doSelect(c, conn); - - return result.get(0); - } - - /** - * Returns the number of rows in a query. - * - * @param c Criteria to get the count for. - * @param conn Connection to use - * @param columnName Name of database Column which is counted. Preferably, - * use the primary key here. - * @param tableMap the table to count the columns in, or null to determine - * the table automatically from the criteria. - * - * @return number of rows matching the query provided. - * - * @throws TorqueException if the query could not be executed. */ public int count( - org.apache.torque.criteria.Criteria c, - Connection conn, - String columnName, - TableMap tableMap) + final Criteria c, + final Connection conn, + final String columnName, + final TableMap tableMap) throws TorqueException { /* Clear the select columns. */
Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java?rev=1484252&r1=1484251&r2=1484252&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java Sun May 19 09:58:00 2013 @@ -34,7 +34,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.torque.Torque; import org.apache.torque.TorqueException; -import org.apache.torque.criteria.CriteriaInterface; +import org.apache.torque.criteria.Criteria; import org.apache.torque.sql.SqlBuilder; /** @@ -167,7 +167,7 @@ public class LargeSelect<T> implements R private int totalRecords = 0; /** The criteria used for the query. */ - private CriteriaInterface<?> criteria = null; + private Criteria criteria = null; /** The last page of results that were returned. */ private transient List<T> lastResults; @@ -239,9 +239,9 @@ public class LargeSelect<T> implements R * the Criteria object does not contain SELECT columns. */ public LargeSelect( - CriteriaInterface<?> criteria, - int pageSize, - BasePeerImpl<T> peerImpl) + final Criteria criteria, + final int pageSize, + final BasePeerImpl<T> peerImpl) { this( criteria, @@ -272,10 +272,10 @@ public class LargeSelect<T> implements R * contain SELECT columns.. */ public LargeSelect( - CriteriaInterface<?> criteria, - int pageSize, - int memoryPageLimit, - BasePeerImpl<T> peerImpl) + final Criteria criteria, + final int pageSize, + final int memoryPageLimit, + final BasePeerImpl<T> peerImpl) { this.peer = peerImpl; @@ -316,7 +316,7 @@ public class LargeSelect<T> implements R * greater than zero. * @throws TorqueException if a sleep is unexpectedly interrupted. */ - public List<T> getPage(int pageNumber) throws TorqueException + public List<T> getPage(final int pageNumber) throws TorqueException { if (pageNumber < 1) { @@ -389,7 +389,7 @@ public class LargeSelect<T> implements R * <code>pageSize</code> results. * @throws TorqueException if a sleep is unexpectedly interrupted. */ - private List<T> getResults(int start) throws TorqueException + private List<T> getResults(final int start) throws TorqueException { return getResults(start, pageSize); } @@ -407,7 +407,7 @@ public class LargeSelect<T> implements R * not catered for. * @throws TorqueException if a sleep is unexpectedly interrupted. */ - private synchronized List<T> getResults(int start, int size) + private synchronized List<T> getResults(final int start, final int size) throws TorqueException { if (log.isDebugEnabled()) @@ -547,21 +547,12 @@ public class LargeSelect<T> implements R * columns not fully qualified will not be modified. */ String query; - if (criteria instanceof Criteria) - { - peer.correctBooleans((Criteria) criteria); - peer.setDbName((Criteria) criteria); - query = SqlBuilder.buildQuery((Criteria) criteria).toString(); - } - else - { - peer.correctBooleans( - (org.apache.torque.criteria.Criteria) criteria); - peer.setDbName((org.apache.torque.criteria.Criteria) criteria); - query = SqlBuilder.buildQuery( - (org.apache.torque.criteria.Criteria) criteria) - .toString(); - } + peer.correctBooleans( + criteria); + peer.setDbName(criteria); + query = SqlBuilder.buildQuery( + criteria) + .toString(); // Execute the query. if (log.isDebugEnabled()) @@ -588,19 +579,9 @@ public class LargeSelect<T> implements R log.debug("run(): Invoking BasePeerImpl.doSelect()"); } - List<T> tempResults; - if (criteria instanceof Criteria) - { - tempResults = peer.doSelect( - (Criteria) criteria, - conn); - } - else - { - tempResults = peer.doSelect( - (org.apache.torque.criteria.Criteria) criteria, - conn); - } + List<T> tempResults = peer.doSelect( + criteria, + conn); if (tempResults.size() < criteria.getLimit()) { @@ -694,7 +675,7 @@ public class LargeSelect<T> implements R * * @param initialSize the initial size for each block. */ - private synchronized void startQuery(int initialSize) + private synchronized void startQuery(final int initialSize) { if (log.isDebugEnabled()) { @@ -848,7 +829,7 @@ public class LargeSelect<T> implements R * @param moreIndicator the indicator to use in place of the default * (">"). */ - public void setMoreIndicator(String moreIndicator) + public void setMoreIndicator(final String moreIndicator) { this.moreIndicator = moreIndicator; } @@ -869,7 +850,7 @@ public class LargeSelect<T> implements R * @param memoryPageLimit the maximum number of pages to be in memory * at one time. */ - public void setMemoryPageLimit(int memoryPageLimit) + public void setMemoryPageLimit(final int memoryPageLimit) { this.memoryPageLimit = memoryPageLimit; } @@ -1052,7 +1033,7 @@ public class LargeSelect<T> implements R * @param name the search parameter key to retrieve. * @return the value of the search parameter. */ - public String getSearchParam(String name) + public String getSearchParam(final String name) { return getSearchParam(name, null); } @@ -1068,7 +1049,7 @@ public class LargeSelect<T> implements R * @param defaultValue the default value to return if the key is not found. * @return the value of the search parameter. */ - public String getSearchParam(String name, String defaultValue) + public String getSearchParam(final String name, final String defaultValue) { if (null == params) { @@ -1085,7 +1066,7 @@ public class LargeSelect<T> implements R * @param name the search parameter key to set. * @param value the value of the search parameter to store. */ - public void setSearchParam(String name, String value) + public void setSearchParam(final String name, final String value) { if (null == value) { @@ -1109,7 +1090,7 @@ public class LargeSelect<T> implements R * * @param name the search parameter key to remove. */ - public void removeSearchParam(String name) + public void removeSearchParam(final String name) { if (null != params) { @@ -1124,7 +1105,7 @@ public class LargeSelect<T> implements R * @throws IOException * @throws ClassNotFoundException */ - private void readObject(ObjectInputStream inputStream) + private void readObject(final ObjectInputStream inputStream) throws IOException, ClassNotFoundException { inputStream.defaultReadObject(); Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java?rev=1484252&r1=1484251&r2=1484252&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java Sun May 19 09:58:00 2013 @@ -36,6 +36,7 @@ import org.apache.commons.logging.LogFac import org.apache.torque.Column; import org.apache.torque.ColumnImpl; import org.apache.torque.TorqueException; +import org.apache.torque.criteria.Criteria; import org.apache.torque.criteria.SqlEnum; import org.apache.torque.om.mapper.ObjectListMapper; import org.apache.torque.om.mapper.RecordMapper; @@ -114,34 +115,9 @@ public class SummaryHelper * @return Results as a OrderMap<String, List<Object>> object. * * @throws TorqueException if a database error occurs. - * - * @deprecated please use - * summarize(org.apache.torque.criteria.Criteria) - * instead. - * This method will be removed in a future version of Torque. - */ - @Deprecated - public List<ListOrderedMapCI> summarize(Criteria crit) - throws TorqueException - { - return summarize(crit, (List<Class<?>>) null); - } - - /** - * Return a list of ListOrderedMapCI objects with the results of the summary - * query. The ListOrderedMapCI objects have a key of the column name or - * function alias and are in the order generated by the query. - * The class of the return values are decided by the database driver, - * which makes this method not database independent. - * - * @param crit The base criteria to build on. - * - * @return Results as a OrderMap<String, List<Object>> object. - * - * @throws TorqueException if a database error occurs. */ public List<ListOrderedMapCI> summarize( - org.apache.torque.criteria.Criteria crit) + final Criteria crit) throws TorqueException { return summarize(crit, (List<Class<?>>) null); @@ -161,54 +137,10 @@ public class SummaryHelper * @return Results as a ListOrderMapCI<String, List<Object>> object. * * @throws TorqueException if a database error occurs. - * - * @deprecated Please use - * summarize(org.apache.torque.criteria.Criteria, List<Class<?>>) - * instead. - * This method will be removed in a future version of Torque. */ - @Deprecated public List<ListOrderedMapCI> summarize( - Criteria crit, - List<Class<?>> resultTypes) - throws TorqueException - { - Connection connection = null; - try - { - connection = Transaction.begin(crit.getDbName()); - List<ListOrderedMapCI> result = summarize(crit, resultTypes, connection); - Transaction.commit(connection); - connection = null; - return result; - } - finally - { - if (connection != null) - { - Transaction.safeRollback(connection); - } - } - } - - /** - * Return a list of ListOrderedMapCI objects with the results of the summary - * query. The ListOrderedMapCI objects have a key of the column name or - * function alias and are in the order generated by the query. - * - * @param crit The base criteria to build on. - * @param resultTypes the classes to which the return values of the query - * should be cast, or null to let the database driver decide. - * See org.apache.torque.om.mapper.ObjectListMapper�for the supported - * classes. - * - * @return Results as a ListOrderMapCI<String, List<Object>> object. - * - * @throws TorqueException if a database error occurs. - */ - public List<ListOrderedMapCI> summarize( - org.apache.torque.criteria.Criteria crit, - List<Class<?>> resultTypes) + final Criteria crit, + final List<Class<?>> resultTypes) throws TorqueException { Connection connection = null; @@ -242,36 +174,10 @@ public class SummaryHelper * @return Results as a OrderMap<String, List<Object>> object. * * @throws TorqueException if a database error occurs. - * - * @deprecated please use - * summarize(org.apache.torque.criteria.Criteria, Connection) - * instead. - * This method will be removed in a future version of Torque. - */ - @Deprecated - public List<ListOrderedMapCI> summarize(Criteria crit, Connection conn) - throws TorqueException - { - return summarize(crit, null, conn); - } - - /** - * Return a list of OrderedMap objects with the results of the summary - * query. The OrderedMap objects have a key of the column name or - * function alias and are in the order generated by the query. - * The class of the return values are decided by the database driver, - * which makes this method not database independent. - * - * @param crit The base criteria to build on. - * @param conn The DB Connection to use. - * - * @return Results as a OrderMap<String, List<Object>> object. - * - * @throws TorqueException if a database error occurs. */ public List<ListOrderedMapCI> summarize( - org.apache.torque.criteria.Criteria crit, - Connection conn) + final Criteria crit, + final Connection conn) throws TorqueException { return summarize(crit, null, conn); @@ -292,17 +198,11 @@ public class SummaryHelper * @return Results as a ListOrderedMapCI<String,Values> object. * * @throws TorqueException if a database error occurs. - * - * @deprecated please use - * summarize(org.apache.torque.criteria.Criteria, List<Class<?>>, Connection) - * instead. - * This method will be removed in a future version of Torque. */ - @Deprecated public List<ListOrderedMapCI> summarize( - Criteria crit, - List<Class<?>> resultTypes, - Connection conn) + final Criteria crit, + final List<Class<?>> resultTypes, + final Connection conn) throws TorqueException { Criteria c = buildCriteria(crit); @@ -393,202 +293,6 @@ public class SummaryHelper } /** - * Return a list of ListOrderedMapCI objects with the results of the summary - * query. The ListOrderedMapCI objects have a key of the column name or - * function alias and are in the order generated by the query. - * - * @param crit The base criteria to build on. - * @param resultTypes the classes to which the return values of the query - * should be cast, or null to let the database driver decide. - * See org.apache.torque.om.mapper.ObjectListMapper�for the supported - * classes. - * @param conn The DB Connection to use. - * - * @return Results as a ListOrderedMapCI<String,Values> object. - * - * @throws TorqueException if a database error occurs. - */ - public List<ListOrderedMapCI> summarize( - org.apache.torque.criteria.Criteria crit, - List<Class<?>> resultTypes, - Connection conn) - throws TorqueException - { - org.apache.torque.criteria.Criteria c = buildCriteria(crit); - // TODO use BasePeerImpl.doSelect instead of parsing the result manually - String query = SqlBuilder.buildQuery(c).toString(); - RecordMapper<List<Object>> mapper = new ObjectListMapper(resultTypes); - - Statement statement = null; - ResultSet resultSet = null; - List<List<Object>> rows = new ArrayList<List<Object>>(); - try - { - statement = conn.createStatement(); - long startTime = System.currentTimeMillis(); - logger.debug("Executing query " + query); - - resultSet = statement.executeQuery(query.toString()); - long queryEndTime = System.currentTimeMillis(); - logger.trace("query took " + (queryEndTime - startTime) - + " milliseconds"); - - while (resultSet.next()) - { - List<Object> rowResult = mapper.processRow(resultSet, 0, null); - rows.add(rowResult); - } - long mappingEndTime = System.currentTimeMillis(); - logger.trace("mapping took " + (mappingEndTime - queryEndTime) - + " milliseconds"); - } - catch (SQLException e) - { - throw new TorqueException(e); - } - finally - { - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException e) - { - logger.warn("error closing resultSet", e); - } - } - if (statement != null) - { - try - { - statement.close(); - } - catch (SQLException e) - { - logger.warn("error closing statement", e); - } - } - } - - List<ListOrderedMapCI> resultsList = new Vector<ListOrderedMapCI>(rows.size()); - List<String> columnNames = new ArrayList<String>(); - for (Column column : c.getSelectColumns()) - { - columnNames.add(column.getColumnName()); - } - columnNames.addAll(c.getAsColumns().keySet()); - for (List<Object> row : rows) - { - ListOrderedMapCI recordMap = new ListOrderedMapCI(); - for (int i = 0; i < row.size(); i++) - { - Object value = row.get(i); - String cName = columnNames.get(i); - if (cName == null || cName.equals("")) - { - if (excludeExprColumns()) - { - continue; - } - cName = "Expr" + i; - } - recordMap.put(cName, value); - } - resultsList.add(recordMap); - } - return resultsList; - } - - /** - * Builds the criteria to use in summarizing the information. Note that - * the criteria passed in will be modified. - * - * @param c The base criteria to build the summary criteria from. - * @return A criteria to use in summarizing the information. - * @throws TorqueException - * - * @deprecated please use - * buildCriteria(org.apache.torque.criteria.Criteria) - * instead. - * This method will be removed in a future version of Torque. - */ - @Deprecated - public Criteria buildCriteria(Criteria c) throws TorqueException - { - c.getSelectColumns().clear(); - c.getGroupByColumns().clear(); - - UniqueList<String> criteriaSelectModifiers; - criteriaSelectModifiers = c.getSelectModifiers(); - - if (criteriaSelectModifiers != null - && criteriaSelectModifiers.size() > 0 - && criteriaSelectModifiers.contains(SqlEnum.DISTINCT.toString())) - { - criteriaSelectModifiers.remove(SqlEnum.DISTINCT.toString()); - } - c.setIgnoreCase(false); - - List<Column> cols = getGroupByColumns(); - boolean haveFromTable = !cols.isEmpty(); // Group By cols define src table. - for (Column col : cols) - { - c.addGroupByColumn(col); - c.addSelectColumn(col); - } - if (haveFromTable) - { - logger.debug("From table defined by Group By Cols"); - } - - // Check if the from table is set via a where clause. - if (!haveFromTable && !c.isEmpty()) - { - haveFromTable = true; - logger.debug("From table defined by a where clause"); - } - - ListOrderedMapCI cMap = getAggregates(); - OrderedMapIterator iMap = cMap.orderedMapIterator(); - while (iMap.hasNext()) - { - String key = (String) iMap.next(); - SQLFunction f = (SQLFunction) iMap.getValue(); - Column col = f.getColumn(); - c.addAsColumn(key, new ColumnImpl( - null, - col.getTableName(), - col.getColumnName(), - f.getSqlExpression())); - if (!haveFromTable) // Last chance. Get it from the func. - { - { - // Kludgy Where table.col = table.col clause to force - // from table identification. - c.add(col, - (col.getColumnName() - + "=" + col.getColumnName()), - SqlEnum.CUSTOM); - haveFromTable = true; - - String table = col.getTableName(); - logger.debug("From table, '" + table - + "', defined from aggregate column"); - } - } - } - if (!haveFromTable) - { - throw new TorqueException( - "No FROM table defined by the GroupBy set, " - + "criteria.setAlias, or specified function column!"); - } - return c; - } - - /** * Builds the criteria to use in summarizing the information. Note that * the criteria passed in will be modified. * @@ -596,8 +300,7 @@ public class SummaryHelper * @return A criteria to use in summarizing the information. * @throws TorqueException */ - public org.apache.torque.criteria.Criteria buildCriteria( - org.apache.torque.criteria.Criteria c) throws TorqueException + public Criteria buildCriteria(final Criteria c) throws TorqueException { c.getSelectColumns().clear(); c.getGroupByColumns().clear(); @@ -649,10 +352,9 @@ public class SummaryHelper { // Kludgy Where table.col = table.col clause to force // from table identification. - c.and(col, - (col.getColumnName() - + "=" + col.getColumnName()), - SqlEnum.CUSTOM); + c.andVerbatimSql( + col.getColumnName() + "=" + col.getColumnName(), + new Object[] {}); haveFromTable = true; String table = col.getTableName(); @@ -684,7 +386,7 @@ public class SummaryHelper * * @param column */ - public void addGroupBy(Column column) + public void addGroupBy(final Column column) { getGroupByColumns().add(column); } @@ -696,7 +398,7 @@ public class SummaryHelper * no key words, e.g. function names. * @param function One of the inner classes from the Aggregate class. */ - public void addAggregate(String alias, SQLFunction function) + public void addAggregate(final String alias, final SQLFunction function) { getAggregates().put(alias, function); } @@ -747,7 +449,7 @@ public class SummaryHelper * @param includeHeader * @throws IOException */ - public void dumpResults(Writer out, List<?> results, boolean includeHeader) + public void dumpResults(final Writer out, final List<?> results, final boolean includeHeader) throws IOException { Iterator<?> i = results.iterator(); @@ -808,7 +510,7 @@ public class SummaryHelper * * @param excludeExprColumns if True, these columns won't be included. */ - public void setExcludeExprColumns(boolean excludeExprColumns) + public void setExcludeExprColumns(final boolean excludeExprColumns) { this.excludeExprColumns = excludeExprColumns; } Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/TorqueInstanceTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/TorqueInstanceTest.java?rev=1484252&r1=1484251&r2=1484252&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/TorqueInstanceTest.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/TorqueInstanceTest.java Sun May 19 09:58:00 2013 @@ -121,9 +121,6 @@ public class TorqueInstanceTest extends assertEquals( "defaultschema", databases.get(POSTGRESQL_NAME).getSchema()); - assertEquals( - "orschema2", - databases.get(ORACLE_NAME).getSchema()); } public void testShutdown() throws Exception 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=1484252&r1=1484251&r2=1484252&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 Sun May 19 09:58:00 2013 @@ -60,15 +60,15 @@ public class CriterionTest extends BaseT "myValue"); Criterion innerCriterion = (new Criterion( new ColumnImpl("myTable", "myColumn2"), - "myColumn2<abs(myValue2)", - SqlEnum.CUSTOM)); + "myValue2", + SqlEnum.LESS_THAN)); innerCriterion.and(new Criterion( new ColumnImpl("myTable", "myColumn3"), 3, SqlEnum.GREATER_EQUAL)); criterion.or(innerCriterion); assertEquals("myTable.myColumn=myValue " - + "OR (myColumn2<abs(myValue2) " + + "OR (myTable.myColumn2<myValue2 " + "AND myTable.myColumn3>=3)", criterion.toString()); } Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java?rev=1484252&r1=1484251&r2=1484252&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java (original) +++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java Sun May 19 09:58:00 2013 @@ -1547,28 +1547,6 @@ public class SqlBuilderTest extends Base } - public void testCustom() throws Exception - { - Criteria criteria = new Criteria(); - criteria.addSelectColumn(new ColumnImpl("table.column")); - criteria.where("A", "A = functionOf(B)", SqlEnum.CUSTOM); - Query query = SqlBuilder.buildQuery(criteria); - assertEquals("SELECT table.column FROM table WHERE A = functionOf(B)", - query.toString()); - assertEquals(0, query.getPreparedStatementReplacements().size()); - } - - public void testCustomLvalueNull() throws Exception - { - Criteria criteria = new Criteria(); - criteria.addSelectColumn(new ColumnImpl("table.column")); - criteria.where(null, "A = functionOf(B)", SqlEnum.CUSTOM); - Query query = SqlBuilder.buildQuery(criteria); - assertEquals("SELECT table.column FROM table WHERE A = functionOf(B)", - query.toString()); - assertEquals(0, query.getPreparedStatementReplacements().size()); - } - public void testCriterionCustomSql() throws Exception { Criteria criteria = new Criteria(); @@ -1582,25 +1560,6 @@ public class SqlBuilderTest extends Base assertEquals(0, query.getPreparedStatementReplacements().size()); } - public void testCriterionCustomNoString() throws Exception - { - Criteria criteria = new Criteria(); - criteria.addSelectColumn(new ColumnImpl("table.column")); - Criterion criterion - = new Criterion("A", 3, SqlEnum.CUSTOM); - criteria.where(criterion); - try - { - SqlBuilder.buildQuery(criteria); - fail("Exception expected"); - } - catch (TorqueException e) - { - assertEquals( - "rValue must be a String for the operator CUSTOM", - e.getMessage()); - } - } public void testLvalueIsObject() throws Exception { Criteria criteria = new Criteria(); Modified: db/torque/torque4/trunk/torque-runtime/src/test/resources/torque-schematest.properties URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/resources/torque-schematest.properties?rev=1484252&r1=1484251&r2=1484252&view=diff ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/test/resources/torque-schematest.properties (original) +++ db/torque/torque4/trunk/torque-runtime/src/test/resources/torque-schematest.properties Sun May 19 09:58:00 2013 @@ -20,16 +20,11 @@ torque.database.default = postgresql torque.database.mysql.adapter=mysql torque.dsfactory.mysql.factory= org.apache.torque.dsfactory.SharedPoolDataSourceFactory -torque.dsfactory.mysql.schema=myschema +torque.database.mysql.schema=myschema torque.database.postgresql.adapter=postgresql torque.dsfactory.postgresql.factory= org.apache.torque.dsfactory.SharedPoolDataSourceFactory -torque.database.oracle.adapter=oracle -torque.dsfactory.oracle.factory= org.apache.torque.dsfactory.SharedPoolDataSourceFactory -torque.dsfactory.oracle.schema= orschema1 -torque.database.oracle.schema=orschema2 - torque.idbroker.prefetch=false torque.defaults.schema = defaultschema --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
