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 2011/05/14 19:34:25 UTC
svn commit: r1103171 [1/4] - in /db/torque/torque4/trunk:
torque-runtime/src/main/java/org/apache/torque/util/
torque-runtime/src/test/java/org/apache/torque/sql/
torque-runtime/src/test/java/org/apache/torque/util/
torque-templates/src/main/java/org/a...
Author: tfischer
Date: Sat May 14 17:34:23 2011
New Revision: 1103171
URL: http://svn.apache.org/viewvc?rev=1103171&view=rev
Log:
- divide Peers into static wrapper and implementation class
- make RecordMappers top level classes
Added:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
- copied, changed from r1100619, db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/recordMapper.xml
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/log.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/peerImplCreator.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/peerImplField.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/peerImplGetter.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/peerImplSetter.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/addSelectColumns.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/addSelectColumns.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildColumnValues.vm
- copied, changed from r1062315, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildColumnValues.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildCriteria.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildSelectCriteria.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildSelectCriteria.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/classJavadoc.vm
- copied unchanged from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classJavadoc.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/correctBooleans.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/correctBooleans.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm
- copied, changed from r1098715, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doInsert.vm
- copied, changed from r1062315, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doSelect.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doSelectJoin.vm
- copied, changed from r1098717, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doSelectJoinAllExcept.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/getOMClass.vm
- copied, changed from r1070070, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/getTableMap.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getTableMap.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm
- copied, changed from r1070071, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/log.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/mapBuilderGetter.vm
- copied unchanged from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderGetter.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/mapBuilderInit.vm
- copied unchanged from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderInit.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/numColumnConstant.vm
- copied unchanged from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/numColumnConstant.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/resultSet2Objects.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/resultSet2Objects.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/retrieveByPK.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPKs.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/retrieveByPKs.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/setDbName.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/setDbName.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/classJavadoc.vm
- copied unchanged from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/classJavadoc.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/peerImpl.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/peer.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/createDbObjectInstanceFromInheritance.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/createDbObjectInstanceFromInheritance.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/dbObjectFieldGetter.vm
- copied unchanged from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/dbObjectFieldGetter.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/base/recordMapperBase.vm
- copied, changed from r1056939, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/recordMapper.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/recordmapper/recordMapper.vm
Removed:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/createDbObjectInstanceFromInheritance.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/dbObjectFieldGetter.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/recordMapper.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/setDbName.vm
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/QueryTest.java
db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java
db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/CriteriaTest.java
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/TableAttributeName.java
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/control.xml
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peer.xml
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/addSelectColumns.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildColumnValues.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildCriteria.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildSelectCriteria.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/correctBooleans.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getTableMap.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/mapBuilderGetter.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/resultSet2Objects.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/retrieveByPK.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/retrieveByPKs.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/classJavadoc.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/transformer/om/OMTableTransformer.properties
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java
Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java?rev=1103171&r1=1103170&r2=1103171&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java Sat May 14 17:34:23 2011
@@ -20,36 +20,15 @@ package org.apache.torque.util;
*/
import java.io.Serializable;
-import java.math.BigDecimal;
import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Types;
-import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.torque.Database;
-import org.apache.torque.TooManyRowsException;
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
-import org.apache.torque.map.ColumnMap;
-import org.apache.torque.map.DatabaseMap;
import org.apache.torque.map.MapBuilder;
import org.apache.torque.map.TableMap;
-import org.apache.torque.oid.IdGenerator;
-import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
-import org.apache.torque.om.SimpleKey;
-import org.apache.torque.om.StringKey;
import org.apache.torque.om.mapper.RecordMapper;
-import org.apache.torque.sql.Query;
-import org.apache.torque.sql.SqlBuilder;
/**
* This is the base class for all Peer classes in the system. Peer
@@ -76,32 +55,35 @@ public abstract class BasePeer
*/
private static final long serialVersionUID = -7702123730779032381L;
- /** Constant criteria key to reference ORDER BY columns. */
- public static final String ORDER_BY = "ORDER BY";
+ /** The BasePeerImpl instance to delegate to. */
+ private static BasePeerImpl basePeerImpl;
/**
- * Constant criteria key to remove Case Information from
- * search/ordering criteria.
+ * Returns an instance of the implementation of the peer.
+ * If no instance is currently cached, a new instance is created and cached.
+ *
+ * @return an instance of the implementation of the peer, not null.
*/
- public static final String IGNORE_CASE = "IgNOrE cAsE";
-
- /** Classes that implement this class should override this value. */
- public static final String TABLE_NAME = "TABLE_NAME";
-
- /** the log */
- private static final Log log = LogFactory.getLog(BasePeer.class);
-
- private static void throwTorqueException(Exception e)
- throws TorqueException
+ public static BasePeerImpl getBasePeerImpl()
{
- if (e instanceof TorqueException)
- {
- throw (TorqueException) e;
- }
- else
+ BasePeerImpl peerImplInstance = basePeerImpl;
+ if (peerImplInstance == null)
{
- throw new TorqueException(e);
+ peerImplInstance = new BasePeerImpl();
+ basePeerImpl = peerImplInstance;
}
+ return peerImplInstance;
+ }
+
+ /**
+ * Sets the implementation instance of this peer.
+ *
+ * @param basePeerImpl the implementation, or null to force creation of a
+ * new instance.
+ */
+ public static void setBasePeerImpl(BasePeerImpl basePeerImpl)
+ {
+ BasePeer.basePeerImpl = basePeerImpl;
}
/**
@@ -111,16 +93,11 @@ public abstract class BasePeer
* @param columnNames A String[].
* @return A String[].
*/
- public static String[] initCriteriaKeys(
+ public String[] initCriteriaKeys(
String tableName,
String[] columnNames)
{
- String[] keys = new String[columnNames.length];
- for (int i = 0; i < columnNames.length; i++)
- {
- keys[i] = tableName + "." + columnNames[i].toUpperCase();
- }
- return keys;
+ return getBasePeerImpl().initCriteriaKeys(tableName, columnNames);
}
/**
@@ -142,39 +119,7 @@ public abstract class BasePeer
int value)
throws TorqueException
{
- Statement statement = null;
- try
- {
- statement = con.createStatement();
-
- StringBuffer query = new StringBuffer();
- query.append("DELETE FROM ")
- .append(table)
- .append(" WHERE ")
- .append(column)
- .append(" = ")
- .append(value);
-
- statement.executeUpdate(query.toString());
- }
- catch (SQLException e)
- {
- throw new TorqueException(e);
- }
- finally
- {
- if (statement != null)
- {
- try
- {
- statement.close();
- }
- catch (SQLException e)
- {
- throw new TorqueException(e);
- }
- }
- }
+ getBasePeerImpl().deleteAll(con, table, column, value);
}
/**
@@ -192,17 +137,7 @@ public abstract class BasePeer
public static void deleteAll(String table, String column, int value)
throws TorqueException
{
- Connection con = null;
- try
- {
- // Get a connection to the db.
- con = Torque.getConnection(Torque.getDefaultDB());
- deleteAll(con, table, column, value);
- }
- finally
- {
- Torque.closeConnection(con);
- }
+ getBasePeerImpl().deleteAll(table, column, value);
}
/**
@@ -217,7 +152,7 @@ public abstract class BasePeer
*/
public static void doDelete(Criteria criteria) throws TorqueException
{
- doDelete(criteria, (String) null);
+ getBasePeerImpl().doDelete(criteria);
}
/**
@@ -237,20 +172,7 @@ public abstract class BasePeer
protected static void doDelete(Criteria criteria, String tableName)
throws TorqueException
{
- Connection con = null;
- try
- {
- con = Transaction.beginOptional(
- criteria.getDbName(),
- criteria.isUseTransaction());
- doDelete(criteria, tableName, con);
- Transaction.commit(con);
- }
- catch (TorqueException e)
- {
- Transaction.safeRollback(con);
- throw e;
- }
+ getBasePeerImpl().doDelete(criteria, tableName);
}
/**
@@ -266,14 +188,7 @@ public abstract class BasePeer
public static void doDelete(Criteria criteria, Connection con)
throws TorqueException
{
- Criteria.Criterion criterion
- = (Criteria.Criterion) criteria.values().iterator().next();
- String tableName = criterion.getTable();
- if (tableName == null)
- {
- throw new TorqueException("Unqualified column name in criteria");
- }
- doDelete(criteria, tableName, con);
+ getBasePeerImpl().doDelete(criteria, con);
}
/**
@@ -293,95 +208,7 @@ public abstract class BasePeer
Connection connection)
throws TorqueException
{
-// String dbName = criteria.getDbName();
-// final DatabaseMap dbMap = Torque.getDatabaseMap(dbName);
-
- // This Callback adds all tables to the Table set which
- // are referenced from a cascading criteria. As a result, all
- // data that is referenced through foreign keys will also be
- // deleted.
-// TODO: reimplement
-// SQLBuilder.TableCallback tc = new SQLBuilder.TableCallback() {
-// public void process (Set<String> tables, String key, Criteria crit)
-// {
-// if (crit.isCascade())
-// {
-// // This steps thru all the columns in the database.
-// TableMap[] tableMaps = dbMap.getTables();
-// for (int i = 0; i < tableMaps.length; i++)
-// {
-// ColumnMap[] columnMaps = tableMaps[i].getColumns();
-//
-// for (int j = 0; j < columnMaps.length; j++)
-// {
-// // Only delete rows where the foreign key is
-// // also a primary key. Other rows need
-// // updating, but that is not implemented.
-// if (columnMaps[j].isForeignKey()
-// && columnMaps[j].isPrimaryKey()
-// && key.equals(columnMaps[j].getRelatedName()))
-// {
-// tables.add(tableMaps[i].getName());
-// crit.add(columnMaps[j].getFullyQualifiedName(),
-// crit.getValue(key));
-// }
-// }
-// }
-// }
-// }
-// };
-
- Query query = createQuery(criteria);
-
- query.setType(Query.Type.DELETE);
- query.getFromClause().clear();
- String fullTableName = SqlBuilder.getFullTableName(
- tableName,
- criteria.getDbName());
- query.getFromClause().add(
- new Query.FromElement(fullTableName, null, null));
- String sql = query.toString();
-
- PreparedStatement preparedStatement = null;
- try
- {
- preparedStatement = connection.prepareStatement(sql);
- setPreparedStatementReplacements(
- preparedStatement,
- query.getPreparedStatementReplacements(),
- 0);
- long startTime = System.currentTimeMillis();
- log.debug("Executing delete " + sql
- + ", parameters = "
- + query.getPreparedStatementReplacements());
-
- int affectedRows = preparedStatement.executeUpdate();
- long queryEndTime = System.currentTimeMillis();
- log.trace("delete took " + (queryEndTime - startTime)
- + " milliseconds");
-
- preparedStatement.close();
- preparedStatement = null;
- return affectedRows;
- }
- catch (SQLException e)
- {
- throw new TorqueException(e);
- }
- finally
- {
- if (preparedStatement != null)
- {
- try
- {
- preparedStatement.close();
- }
- catch (SQLException e)
- {
- log.warn("error closing prepared statement", e);
- }
- }
- }
+ return getBasePeerImpl().doDelete(criteria, tableName, connection);
}
/**
@@ -408,36 +235,7 @@ public abstract class BasePeer
public static ObjectKey doInsert(ColumnValues insertValues)
throws TorqueException
{
- String databaseName;
- {
- TableMap table = insertValues.getTable();
- if (table == null)
- {
- log.debug("doUpdate(): no Table set in updateValues, "
- + "using default database");
- databaseName = Torque.getDefaultDB();
- }
- else
- {
- databaseName = table.getDatabaseMap().getName();
- }
- }
- Connection connection = null;
- try
- {
- connection = Transaction.begin(databaseName);
- ObjectKey id = doInsert(insertValues, connection);
- Transaction.commit(connection);
- connection = null;
- return id;
- }
- finally
- {
- if (connection != null)
- {
- Transaction.safeRollback(connection);
- }
- }
+ return getBasePeerImpl().doInsert(insertValues);
}
/**
@@ -467,184 +265,7 @@ public abstract class BasePeer
Connection connection)
throws TorqueException
{
- TableMap tableMap = insertValues.getTable();
- DatabaseMap dbMap = tableMap.getDatabaseMap();
- Database database = Torque.getDatabase(dbMap.getName());
- Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
- IdGenerator keyGen
- = database.getIdGenerator(tableMap.getPrimaryKeyMethod());
-
- SimpleKey id = null;
- // can currently generate only single column pks, therefore a single
- // columnMap is ok
- ColumnMap primaryKey = null;
- if (keyGen != null)
- {
- // fail on multiple pks
- primaryKey = tableMap.getPrimaryKey();
-
- // primaryKey will be null if there is no primary key
- // defined for the table we're inserting into.
- if (keyGen.isPriorToInsert() && primaryKey != null
- && !insertValues.containsKey(
- primaryKey.getFullyQualifiedName()))
- {
- id = getId(primaryKey, keyGen, connection, keyInfo);
- insertValues.put(
- primaryKey.getFullyQualifiedName(),
- new JdbcTypedValue(id.getValue(), id.getJdbcType()));
- }
- }
-
- List<String> columnNames = new ArrayList<String>();
- List<JdbcTypedValue> replacementObjects
- = new ArrayList<JdbcTypedValue>();
- for (Map.Entry<String, JdbcTypedValue> columnValue
- : insertValues.entrySet())
- {
- String columnName = columnValue.getKey();
- if (columnName.lastIndexOf(".") != -1)
- {
- columnName = columnName.substring(
- columnName.lastIndexOf(".") + 1);
- }
- columnNames.add(columnName);
- JdbcTypedValue value = columnValue.getValue();
- replacementObjects.add(value);
- }
-
- String fullTableName = SqlBuilder.getFullTableName(
- tableMap.getName(),
- dbMap.getName());
- StringBuilder query = new StringBuilder("INSERT INTO ")
- .append(fullTableName)
- .append("(")
- .append(StringUtils.join(columnNames, ","))
- .append(") VALUES (");
- for (int i = 0; i < columnNames.size(); ++i)
- {
- if (i != 0)
- {
- query.append(",");
- }
- query.append("?");
- }
- query.append(")");
-
- PreparedStatement preparedStatement = null;
- try
- {
- preparedStatement = connection.prepareStatement(query.toString());
- int position = 1;
- for (JdbcTypedValue replacementObject : replacementObjects)
- {
- Object value = replacementObject.getValue();
- if (value != null)
- {
- if (replacementObject.getJdbcType() != Types.BLOB
- && replacementObject.getJdbcType() != Types.CLOB)
- {
- preparedStatement.setObject(
- position,
- value,
- replacementObject.getJdbcType());
- }
- else
- {
- preparedStatement.setObject(
- position,
- value);
- }
- }
- else
- {
- preparedStatement.setNull(
- position,
- replacementObject.getJdbcType());
- }
- position++;
- }
- long startTime = System.currentTimeMillis();
- log.debug("Executing insert " + query.toString()
- + " using parameters " + replacementObjects);
-
- preparedStatement.executeUpdate();
- long queryEndTime = System.currentTimeMillis();
- log.trace("insert took " + (queryEndTime - startTime)
- + " milliseconds");
-
- preparedStatement.close();
- preparedStatement = null;
- }
- catch (SQLException e)
- {
- throw new TorqueException(e);
- }
- finally
- {
- if (preparedStatement != null)
- {
- try
- {
- preparedStatement.close();
- }
- catch (SQLException e)
- {
- log.warn("error closing prepared statement", e);
- }
- }
- }
-
- // If the primary key column is auto-incremented, get the id
- // now.
- if (keyGen != null && keyGen.isPostInsert())
- {
- id = getId(primaryKey, keyGen, connection, keyInfo);
- }
-
- return id;
- }
-
- /**
- * Create an Id for insertion in the Criteria
- *
- * @param pk ColumnMap for the Primary key
- * @param keyGen The Id Generator object
- * @param con The SQL Connection to run the id generation under
- * @param keyInfo KeyInfo Parameter from the Table map
- *
- * @return A simple Key representing the new Id value
- * @throws TorqueException Possible errors get wrapped in here.
- */
- private static SimpleKey getId(
- ColumnMap pk,
- IdGenerator keyGen,
- Connection con,
- Object keyInfo)
- throws TorqueException
- {
- SimpleKey id = null;
-
- try
- {
- if (pk != null && keyGen != null)
- {
- if (pk.getType() instanceof Number)
- {
- id = new NumberKey(
- keyGen.getIdAsBigDecimal(con, keyInfo));
- }
- else
- {
- id = new StringKey(keyGen.getIdAsString(con, keyInfo));
- }
- }
- }
- catch (Exception e)
- {
- throwTorqueException(e);
- }
- return id;
+ return getBasePeerImpl().doInsert(insertValues, connection);
}
/**
@@ -658,24 +279,7 @@ public abstract class BasePeer
static String createQueryDisplayString(Criteria criteria)
throws TorqueException
{
- Query query = SqlBuilder.buildQuery(criteria);
- return query.getDisplayString();
- }
-
- /**
- * Method to create an SQL query based on values in a Criteria. Note that
- * final manipulation of the limit and offset are performed when the query
- * is actually executed.
- *
- * @param criteria A Criteria.
- * @return the sql query
- * @exception TorqueException Trouble creating the query string.
- */
- // TODO: remove and replace occurances with implementation
- static Query createQuery(Criteria criteria)
- throws TorqueException
- {
- return SqlBuilder.buildQuery(criteria);
+ return getBasePeerImpl().createQueryDisplayString(criteria);
}
/**
@@ -697,30 +301,7 @@ public abstract class BasePeer
TableMap defaultTableMap)
throws TorqueException
{
- Connection connection = null;
- try
- {
- connection = Transaction.beginOptional(
- criteria.getDbName(),
- criteria.isUseTransaction());
-
- List<T> result = doSelect(
- criteria,
- mapper,
- defaultTableMap,
- connection);
-
- Transaction.commit(connection);
- connection = null;
- return result;
- }
- finally
- {
- if (connection != null)
- {
- Transaction.safeRollback(connection);
- }
- }
+ return getBasePeerImpl().doSelect(criteria, mapper, defaultTableMap);
}
/**
@@ -745,34 +326,11 @@ public abstract class BasePeer
String dbName)
throws TorqueException
{
- if (dbName == null)
- {
- dbName = Torque.getDefaultDB();
- }
- Connection connection = null;
- try
- {
- connection = Transaction.beginOptional(
- dbName,
- true);
-
- List<T> result = doSelect(
- query,
- mapper,
- defaultTableMap,
- connection);
-
- Transaction.commit(connection);
- connection = null;
- return result;
- }
- finally
- {
- if (connection != null)
- {
- Transaction.safeRollback(connection);
- }
- }
+ return getBasePeerImpl().doSelect(
+ query,
+ mapper,
+ defaultTableMap,
+ dbName);
}
/**
@@ -796,315 +354,13 @@ public abstract class BasePeer
Connection connection)
throws TorqueException
{
- if (connection == null)
- {
- throw new NullPointerException("connection is null");
- }
-
- List<T> result = new ArrayList<T>();
- Statement statement = null;
- ResultSet resultSet = null;
- try
- {
- statement = connection.createStatement();
- long startTime = System.currentTimeMillis();
- log.debug("Executing query " + query);
-
- resultSet = statement.executeQuery(query.toString());
- long queryEndTime = System.currentTimeMillis();
- log.trace("query took " + (queryEndTime - startTime)
- + " milliseconds");
-
- while (resultSet.next())
- {
- T rowResult = mapper.processRow(resultSet, 0);
- result.add(rowResult);
- }
- long mappingEndTime = System.currentTimeMillis();
- log.trace("mapping took " + (mappingEndTime - queryEndTime)
- + " milliseconds");
- }
- catch (SQLException e)
- {
- throw new TorqueException(e);
- }
- finally
- {
- if (resultSet != null)
- {
- try
- {
- resultSet.close();
- }
- catch (SQLException e)
- {
- log.warn("error closing resultSet", e);
- }
- }
- if (statement != null)
- {
- try
- {
- statement.close();
- }
- catch (SQLException e)
- {
- log.warn("error closing statement", e);
- }
- }
- }
- return result;
+ return getBasePeerImpl().doSelect(
+ query,
+ mapper,
+ defaultTableMap,
+ connection);
}
-// /**
-// * Helper method which returns the primary key contained
-// * in the given Criteria object.
-// *
-// * @param criteria A Criteria.
-// * @return ColumnMap if the Criteria object contains a primary
-// * key, or null if it doesn't.
-// * @throws TorqueException Any exceptions caught during processing will be
-// * rethrown wrapped into a TorqueException.
-// */
-// private static ColumnMap getPrimaryKey(Criteria criteria)
-// throws TorqueException
-// {
-// // Assume all the keys are for the same table.
-// String key = (String) criteria.keys().nextElement();
-//
-// String table = criteria.getTableName(key);
-// ColumnMap pk = null;
-//
-// if (!table.equals(""))
-// {
-// DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
-// if (dbMap == null)
-// {
-// throw new TorqueException("dbMap is null");
-// }
-// if (dbMap.getTable(table) == null)
-// {
-// throw new TorqueException("dbMap.getTable() is null");
-// }
-//
-// ColumnMap[] columns = dbMap.getTable(table).getColumns();
-//
-// for (int i = 0; i < columns.length; i++)
-// {
-// if (columns[i].isPrimaryKey())
-// {
-// pk = columns[i];
-// break;
-// }
-// }
-// }
-// return pk;
-// }
-//
-// /**
-// * Convenience method used to update rows in the DB. Checks if a
-// * <i>single</i> int primary key is specified in the Criteria
-// * object and uses it to perform the udpate. If no primary key is
-// * specified an Exception will be thrown.
-// * <p>
-// * Use this method for performing an update of the kind:
-// * <p>
-// * "WHERE primary_key_id = an int"
-// * <p>
-// * To perform an update with non-primary key fields in the WHERE
-// * clause use doUpdate(criteria, criteria).
-// *
-// * @param updateValues A Criteria object containing values used in
-// * set clause.
-// *
-// * @return the number of affected rows.
-// *
-// * @throws TorqueException Any exceptions caught during processing will be
-// * rethrown wrapped into a TorqueException.
-// */
-// public static int doUpdate(Criteria updateValues) throws TorqueException
-// {
-// Connection connection = null;
-// try
-// {
-// connection = Transaction.beginOptional(
-// updateValues.getDbName(),
-// updateValues.isUseTransaction());
-// int result = doUpdate(updateValues, connection);
-// Transaction.commit(connection);
-// connection = null;
-// return result;
-// }
-// finally
-// {
-// if (connection != null)
-// {
-// Transaction.safeRollback(connection);
-// }
-// }
-// }
-//
-// /**
-// * Convenience method used to update rows in the DB. Checks if a
-// * <i>single</i> int primary key is specified in the Criteria
-// * object and uses it to perform the udpate. If no primary key is
-// * specified an Exception will be thrown.
-// * <p>
-// * Use this method for performing an update of the kind:
-// * <p>
-// * "WHERE primary_key_id = an int"
-// * <p>
-// * To perform an update with non-primary key fields in the WHERE
-// * clause use doUpdate(criteria, criteria).
-// *
-// * @param updateValues A Criteria object containing values used in
-// * set clause.
-// * @param con A Connection.
-// *
-// * @return the number of affected rows.
-// *
-// * @throws TorqueException Any exceptions caught during processing will be
-// * rethrown wrapped into a TorqueException.
-// */
-// public static int doUpdate(Criteria updateValues, Connection con)
-// throws TorqueException
-// {
-// ColumnMap pk = getPrimaryKey(updateValues);
-// Criteria selectCriteria = null;
-//
-// if (pk != null && updateValues.containsKey(pk.getFullyQualifiedName()))
-// {
-// selectCriteria = new Criteria(2);
-// selectCriteria.put(pk.getFullyQualifiedName(),
-// updateValues.remove(pk.getFullyQualifiedName()));
-// }
-// else
-// {
-// throw new TorqueException("No PK specified for database update");
-// }
-//
-// return doUpdate(selectCriteria, updateValues, con);
-// }
-//
-// /**
-// * Executes an update against the database. The rows to be updated
-// * are selected using <code>criteria</code> and updated using the values
-// * in <code>updateValues</code>.
-// *
-// * @param criteria selects which rows of which table should be updated.
-// * @param updateValues which columns(map keys) should be set to which
-// * values.
-// * @param connection the database connection to use, not null.
-// *
-// * @return the number of affected rows.
-// *
-// * @throws TorqueException if updating fails.
-// */
-// public static void doUpdate(
-// Criteria selectCriteria,
-// Criteria updateValues)
-// throws TorqueException
-// {
-// Connection con = null;
-// try
-// {
-// con = Transaction.beginOptional(
-// selectCriteria.getDbName(),
-// selectCriteria.isUseTransaction());
-// doUpdate(selectCriteria, updateValues, con);
-// Transaction.commit(con);
-// }
-// catch (TorqueException e)
-// {
-// Transaction.safeRollback(con);
-// throw e;
-// }
-// }
-//
-// /**
-// * Executes an update against the database. The rows to be updated
-// * are selected using <code>criteria</code> and updated using the values
-// * in <code>updateValues</code>.
-// *
-// * @param criteria selects which rows of which table should be updated.
-// * @param updateValues which columns(map keys) should be set to which
-// * values.
-// * @param connection the database connection to use, not null.
-// *
-// * @return the number of affected rows.
-// *
-// * @throws TorqueException if updating fails.
-// */
-// public static int doUpdate(
-// Criteria criteria,
-// Criteria updateValues,
-// Connection connection)
-// throws TorqueException
-// {
-// Query sql = createQuery(criteria);
-// sql.setType(Query.Type.UPDATE);
-//
-// // ignore select columns in criteria
-// sql.getSelectClause().clear();
-// List<Object> replacementObjects = new ArrayList<Object>();
-// for (Object updateValueObject : updateValues.entrySet())
-// {
-// Map.Entry<?, ?> updateValue = (Map.Entry<?, ?>) updateValueObject;
-// String columnName = updateValue.getKey().toString();
-// if (columnName.lastIndexOf(".") != -1)
-// {
-// columnName = columnName.substring(
-// columnName.lastIndexOf(".") + 1);
-// }
-// sql.getSelectClause().add(columnName);
-// replacementObjects.add(
-// ((Criteria.Criterion) updateValue.getValue()).getValue());
-// }
-//
-// PreparedStatement preparedStatement = null;
-// try
-// {
-// preparedStatement = connection.prepareStatement(sql.toString());
-// int position = 1;
-// for (Object replacementObject : replacementObjects)
-// {
-// preparedStatement.setObject(position, replacementObject);
-// position++;
-// }
-// long startTime = System.currentTimeMillis();
-// log.debug("Executing update " + sql.toString()
-// + " using parameters " + replacementObjects);
-//
-// int affectedRows = preparedStatement.executeUpdate();
-// long queryEndTime = System.currentTimeMillis();
-// log.trace("update took " + (queryEndTime - startTime)
-// + " milliseconds");
-//
-// preparedStatement.close();
-// preparedStatement = null;
-// return affectedRows;
-// }
-// catch (SQLException e)
-// {
-// throw new TorqueException(e);
-// }
-// finally
-// {
-// if (preparedStatement != null)
-// {
-// try
-// {
-// preparedStatement.close();
-// }
-// catch (SQLException e)
-// {
-// log.warn("error closing prepared statement", e);
-// }
-// }
-// }
-// }
-
-
/**
* Convenience method used to update rows in the DB. Checks if a
* <i>single</i> primary key is specified in the Criteria
@@ -1131,36 +387,7 @@ public abstract class BasePeer
public static int doUpdate(ColumnValues updateValues)
throws TorqueException
{
- String databaseName;
- {
- TableMap table = updateValues.getTable();
- if (table == null)
- {
- log.debug("doUpdate(): no Table set in updateValues, "
- + "using default database");
- databaseName = Torque.getDefaultDB();
- }
- else
- {
- databaseName = table.getDatabaseMap().getName();
- }
- }
- Connection connection = null;
- try
- {
- connection = Transaction.begin(databaseName);
- int result = doUpdate(updateValues, connection);
- Transaction.commit(connection);
- connection = null;
- return result;
- }
- finally
- {
- if (connection != null)
- {
- Transaction.safeRollback(connection);
- }
- }
+ return getBasePeerImpl().doUpdate(updateValues);
}
/**
@@ -1196,22 +423,7 @@ public abstract class BasePeer
Connection connection)
throws TorqueException
{
- TableMap table = updateValues.getTable();
- ColumnMap pk = table.getPrimaryKey();
- Criteria selectCriteria = null;
-
- if (pk != null && updateValues.containsKey(pk.getFullyQualifiedName()))
- {
- selectCriteria = new Criteria(2);
- selectCriteria.put(pk.getFullyQualifiedName(),
- updateValues.remove(pk.getFullyQualifiedName()));
- }
- else
- {
- throw new TorqueException("No PK specified for database update");
- }
-
- return doUpdate(selectCriteria, updateValues, connection);
+ return getBasePeerImpl().doUpdate(updateValues, connection);
}
/**
@@ -1231,36 +443,7 @@ public abstract class BasePeer
ColumnValues updateValues)
throws TorqueException
{
- String databaseName;
- {
- TableMap table = updateValues.getTable();
- if (table == null)
- {
- log.debug("doUpdate(): no Table set in updateValues, "
- + "using default database");
- databaseName = Torque.getDefaultDB();
- }
- else
- {
- databaseName = table.getDatabaseMap().getName();
- }
- }
- Connection connection = null;
- try
- {
- connection = Transaction.begin(databaseName);
- int result = doUpdate(selectCriteria, updateValues, connection);
- Transaction.commit(connection);
- connection = null;
- return result;
- }
- finally
- {
- if (connection != null)
- {
- Transaction.safeRollback(connection);
- }
- }
+ return getBasePeerImpl().doUpdate(selectCriteria, updateValues);
}
/**
@@ -1282,88 +465,7 @@ public abstract class BasePeer
Connection connection)
throws TorqueException
{
- Query query = createQuery(criteria);
- query.setType(Query.Type.UPDATE);
-
- query.getFromClause().clear();
- String fullTableName = SqlBuilder.getFullTableName(
- updateValues.getTable().getName(),
- criteria.getDbName());
- query.getFromClause().add(
- new Query.FromElement(fullTableName, null, null));
-
- List<JdbcTypedValue> replacementObjects
- = new ArrayList<JdbcTypedValue>();
- for (Map.Entry<String, JdbcTypedValue> updateValue
- : updateValues.entrySet())
- {
- String columnName = updateValue.getKey();
- if (columnName.lastIndexOf(".") != -1)
- {
- columnName = columnName.substring(
- columnName.lastIndexOf(".") + 1);
- }
- query.getSelectClause().add(columnName);
- replacementObjects.add(updateValue.getValue());
- }
-
- PreparedStatement preparedStatement = null;
- try
- {
- preparedStatement = connection.prepareStatement(query.toString());
- int position = 1;
- for (JdbcTypedValue replacementObject : replacementObjects)
- {
- Object value = replacementObject.getValue();
- if (value != null)
- {
- preparedStatement.setObject(position, value);
- }
- else
- {
- preparedStatement.setNull(
- position,
- replacementObject.getJdbcType());
- }
- position++;
- }
- setPreparedStatementReplacements(
- preparedStatement,
- query.getPreparedStatementReplacements(),
- position - 1);
- long startTime = System.currentTimeMillis();
- log.debug("Executing update " + query.toString()
- + " using update parameters " + replacementObjects
- + " and query parameters "
- + query.getPreparedStatementReplacements());
-
- int affectedRows = preparedStatement.executeUpdate();
- long queryEndTime = System.currentTimeMillis();
- log.trace("update took " + (queryEndTime - startTime)
- + " milliseconds");
-
- preparedStatement.close();
- preparedStatement = null;
- return affectedRows;
- }
- catch (SQLException e)
- {
- throw new TorqueException(e);
- }
- finally
- {
- if (preparedStatement != null)
- {
- try
- {
- preparedStatement.close();
- }
- catch (SQLException e)
- {
- log.warn("error closing prepared statement", e);
- }
- }
- }
+ return getBasePeerImpl().doUpdate(criteria, updateValues, connection);
}
/**
@@ -1378,7 +480,7 @@ public abstract class BasePeer
*/
public static int executeStatement(String statementString) throws TorqueException
{
- return executeStatement(statementString, Torque.getDefaultDB());
+ return getBasePeerImpl().executeStatement(statementString);
}
/**
@@ -1395,18 +497,7 @@ public abstract class BasePeer
public static int executeStatement(String statementString, String dbName)
throws TorqueException
{
- Connection con = null;
- int rowCount = -1;
- try
- {
- con = Torque.getConnection(dbName);
- rowCount = executeStatement(statementString, con);
- }
- finally
- {
- Torque.closeConnection(con);
- }
- return rowCount;
+ return getBasePeerImpl().executeStatement(statementString, dbName);
}
/**
@@ -1423,32 +514,7 @@ public abstract class BasePeer
public static int executeStatement(String statementString, Connection con)
throws TorqueException
{
- int rowCount = -1;
- Statement statement = null;
- try
- {
- statement = con.createStatement();
- rowCount = statement.executeUpdate(statementString);
- }
- catch (SQLException e)
- {
- throw new TorqueException(e);
- }
- finally
- {
- if (statement != null)
- {
- try
- {
- statement.close();
- }
- catch (SQLException e)
- {
- throw new TorqueException(e);
- }
- }
- }
- return rowCount;
+ return getBasePeerImpl().executeStatement(statementString, con);
}
/**
@@ -1489,190 +555,13 @@ public abstract class BasePeer
Connection connection)
throws TorqueException
{
- correctBooleans(criteria, defaultTableMap);
-
- Query query = SqlBuilder.buildQuery(criteria);
- if (query.getFromClause().isEmpty() && defaultTableMap != null)
- {
- String tableName = SqlBuilder.getFullTableName(
- defaultTableMap.getName(),
- criteria.getDbName());
- query.getFromClause().add(
- new Query.FromElement(tableName, null, null));
- }
-
- PreparedStatement statement = null;
- ResultSet resultSet = null;
- try
- {
- statement = connection.prepareStatement(query.toString());
-
- setPreparedStatementReplacements(
- statement,
- query.getPreparedStatementReplacements(),
- 0);
-
- long startTime = System.currentTimeMillis();
- log.debug("Executing query " + query
- + ", parameters = "
- + query.getPreparedStatementReplacements());
-
- resultSet = statement.executeQuery();
- long queryEndTime = System.currentTimeMillis();
- log.trace("query took " + (queryEndTime - startTime)
- + " milliseconds");
-
- int offset;
- Database database = Torque.getDatabase(criteria.getDbName());
- if (database.getAdapter().supportsNativeOffset())
- {
- offset = 0; //database takes care of offset
- }
- else
- {
- offset = criteria.getOffset();
- }
-
- int limit;
- if (database.getAdapter().supportsNativeLimit())
- {
- limit = -1; //database takes care of offset
- }
- else
- {
- if (database.getAdapter().supportsNativeOffset())
- {
- limit = criteria.getLimit();
- }
- else
- {
- if (criteria.getLimit() == -1)
- {
- limit = criteria.getLimit();
- }
- else
- {
- limit = offset + criteria.getLimit();
- }
- }
- }
-
- List<T> result = new ArrayList<T>();
- int rowNumber = 0;
- while (resultSet.next())
- {
- if (rowNumber < offset)
- {
- rowNumber++;
- continue;
- }
- if (limit >= 0 && rowNumber >= limit)
- {
- break;
- }
-
- T rowResult = mapper.processRow(resultSet, 0);
- result.add(rowResult);
-
- rowNumber++;
- }
- long mappingEndTime = System.currentTimeMillis();
- log.trace("mapping took " + (mappingEndTime - queryEndTime)
- + " milliseconds");
-
- if (criteria.isSingleRecord() && result.size() > 1)
- {
- throw new TooManyRowsException(
- "Criteria expected single Record and "
- + "Multiple Records were selected");
- }
- return result;
- }
- catch (SQLException e)
- {
- throw new TorqueException(e);
- }
- finally
- {
- if (resultSet != null)
- {
- try
- {
- resultSet.close();
- }
- catch (SQLException e)
- {
- log.warn("error closing resultSet", e);
- }
- }
- if (statement != null)
- {
- try
- {
- statement.close();
- }
- catch (SQLException e)
- {
- log.warn("error closing statement", e);
- }
- }
- }
- }
-
- private static void setPreparedStatementReplacements(
- PreparedStatement statement,
- List<Object> replacements,
- int offset)
- throws SQLException
- {
- int i = 1 + offset;
- for (Object param : replacements)
- {
- if (param instanceof java.sql.Timestamp)
- {
- statement.setTimestamp(i, (java.sql.Timestamp) param);
- }
- else if (param instanceof java.sql.Date)
- {
- statement.setDate(i, (java.sql.Date) param);
- }
- else if (param instanceof java.util.Date)
- {
- // TODO change to timestamp
- java.sql.Date sqlDate = new java.sql.Date(
- ((java.util.Date) param).getTime());
- statement.setDate(i, sqlDate);
- }
- else if (param instanceof NumberKey)
- {
- statement.setBigDecimal(i,
- ((NumberKey) param).getBigDecimal());
- }
- else if (param instanceof Integer)
- {
- statement.setInt(i, ((Integer) param).intValue());
- }
- else if (param instanceof Long)
- {
- statement.setLong(i, ((Long) param).longValue());
- }
- else if (param instanceof BigDecimal)
- {
- statement.setBigDecimal(i, (BigDecimal) param);
- }
- else if (param instanceof Boolean)
- {
- statement.setBoolean(i, ((Boolean) param).booleanValue());
- }
- else
- {
- statement.setString(i, param.toString());
- }
- ++i;
- }
+ return getBasePeerImpl().doSelect(
+ criteria,
+ mapper,
+ defaultTableMap,
+ connection);
}
-
/**
* Checks all columns in the criteria to see whether
* booleanchar and booleanint columns are queried with a boolean.
@@ -1692,108 +581,7 @@ public abstract class BasePeer
TableMap defaultTableMap)
throws TorqueException
{
- for (Object criterionObject : criteria.values())
- {
- Criteria.Criterion criterion = (Criteria.Criterion) criterionObject;
- correctBooleans(criteria, criterion, defaultTableMap);
- }
- }
-
- private static void correctBooleans(
- Criteria criteria,
- Criteria.Criterion criterion,
- TableMap defaultTableMap)
- throws TorqueException
- {
- String tableName = criterion.getTable();
- TableMap tableMap = null;
- if (tableName != null)
- {
- String databaseName = criteria.getDbName();
- if (databaseName == null)
- {
- databaseName = Torque.getDefaultDB();
- }
- DatabaseMap databaseMap = Torque.getDatabaseMap(databaseName);
- if (databaseMap != null)
- {
- tableMap = databaseMap.getTable(tableName);
- }
- if (tableMap == null)
- {
- // try aliases
- Map<String, String> aliases = criteria.getAliases();
- if (aliases.get(tableName) != null)
- {
- tableName = aliases.get(tableName);
- tableMap = databaseMap.getTable(tableName);
- }
- }
- }
- if (tableMap == null)
- {
- tableMap = defaultTableMap;
- }
- // if no description of table available, do not modify anything
- if (tableMap != null)
- {
- String columnName = criterion.getColumn();
- ColumnMap columnMap = tableMap.getColumn(columnName);
- if (columnMap != null)
- {
- if ("BOOLEANINT".equals(columnMap.getTorqueType()))
- {
- replaceBooleanValues(
- criterion,
- new Integer(1),
- new Integer(0));
- }
- else if ("BOOLEANCHAR".equals(columnMap.getTorqueType()))
- {
- replaceBooleanValues(criterion, "Y", "N");
- }
- }
- }
-
- for (Criteria.Criterion attachedCriterion : criterion.getClauses())
- {
- correctBooleans(criteria, attachedCriterion, defaultTableMap);
- }
- }
-
- /**
- * Replaces any Boolean value in the criterion and its attached Criterions
- * by trueValue if the Boolean equals <code>Boolean.TRUE</code>
- * and falseValue if the Boolean equals <code>Boolean.FALSE</code>.
- *
- * @param criterion the criterion to replace Boolean values in.
- * @param trueValue the value by which Boolean.TRUE should be replaced.
- * @param falseValue the value by which Boolean.FALSE should be replaced.
- */
- private static void replaceBooleanValues(
- Criteria.Criterion criterion,
- Object trueValue,
- Object falseValue)
- {
- // attachedCriterions also contains the criterion itself,
- // so no additional treatment is needed for the criterion itself.
- Criteria.Criterion[] attachedCriterions
- = criterion.getAttachedCriterion();
- for (int i = 0; i < attachedCriterions.length; ++i)
- {
- Object criterionValue
- = attachedCriterions[i].getValue();
- if (criterionValue instanceof Boolean)
- {
- Boolean booleanValue = (Boolean) criterionValue;
- attachedCriterions[i].setValue(
- Boolean.TRUE.equals(booleanValue)
- ? trueValue
- : falseValue);
- }
-
- }
-
+ getBasePeerImpl().correctBooleans(criteria, defaultTableMap);
}
/**
@@ -1814,29 +602,6 @@ public abstract class BasePeer
ColumnValues columnValues)
throws TorqueException
{
- TableMap table = columnValues.getTable();
- for (Map.Entry<String, JdbcTypedValue> entry : columnValues.entrySet())
- {
- String columnName = entry.getKey();
- ColumnMap column = table.getColumn(columnName);
- if (column != null)
- {
- JdbcTypedValue columnValue = entry.getValue();
- if ("BOOLEANINT".equals(column.getTorqueType()))
- {
- columnValue.setValue(
- Boolean.TRUE.equals(columnValue.getValue())
- ? new Integer(1)
- : new Integer(0));
- }
- else if ("BOOLEANCHAR".equals(column.getTorqueType()))
- {
- columnValue.setValue(
- Boolean.TRUE.equals(columnValue.getValue())
- ? "Y"
- : "N");
- }
- }
- }
+ getBasePeerImpl().correctBooleans(columnValues);
}
}
Copied: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java (from r1100619, db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java?p2=db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java&p1=db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java&r1=1100619&r2=1103171&rev=1103171&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java Sat May 14 17:34:23 2011
@@ -40,7 +40,6 @@ import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.map.ColumnMap;
import org.apache.torque.map.DatabaseMap;
-import org.apache.torque.map.MapBuilder;
import org.apache.torque.map.TableMap;
import org.apache.torque.oid.IdGenerator;
import org.apache.torque.om.NumberKey;
@@ -68,26 +67,13 @@ import org.apache.torque.sql.SqlBuilder;
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
* @version $Id$
*/
-public abstract class BasePeer
- implements Serializable
+public class BasePeerImpl implements Serializable
{
/**
* Serial Version
*/
private static final long serialVersionUID = -7702123730779032381L;
- /** Constant criteria key to reference ORDER BY columns. */
- public static final String ORDER_BY = "ORDER BY";
-
- /**
- * Constant criteria key to remove Case Information from
- * search/ordering criteria.
- */
- public static final String IGNORE_CASE = "IgNOrE cAsE";
-
- /** Classes that implement this class should override this value. */
- public static final String TABLE_NAME = "TABLE_NAME";
-
/** the log */
private static final Log log = LogFactory.getLog(BasePeer.class);
@@ -111,7 +97,7 @@ public abstract class BasePeer
* @param columnNames A String[].
* @return A String[].
*/
- public static String[] initCriteriaKeys(
+ public String[] initCriteriaKeys(
String tableName,
String[] columnNames)
{
@@ -135,7 +121,7 @@ public abstract class BasePeer
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- public static void deleteAll(
+ public void deleteAll(
Connection con,
String table,
String column,
@@ -189,7 +175,7 @@ public abstract class BasePeer
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- public static void deleteAll(String table, String column, int value)
+ public void deleteAll(String table, String column, int value)
throws TorqueException
{
Connection con = null;
@@ -215,7 +201,7 @@ public abstract class BasePeer
* @deprecated This method causes unexpected results when joins are used.
* Please use doDelete(Criteria, String).
*/
- public static void doDelete(Criteria criteria) throws TorqueException
+ protected void doDelete(Criteria criteria) throws TorqueException
{
doDelete(criteria, (String) null);
}
@@ -223,9 +209,6 @@ public abstract class BasePeer
/**
* Method to perform deletes based on values and keys in a
* Criteria.
- * This method is protected because it may cause ambiguity between
- * doDelete(Criteria,Connection) and this method. It will be made public
- * once doDelete(Criteria, Connection) is removed.
*
* @param criteria The criteria to use.
* @param tableName the name of the table to delete records from.
@@ -234,7 +217,7 @@ public abstract class BasePeer
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- protected static void doDelete(Criteria criteria, String tableName)
+ public void doDelete(Criteria criteria, String tableName)
throws TorqueException
{
Connection con = null;
@@ -263,7 +246,7 @@ public abstract class BasePeer
* @deprecated This method causes unexpected results when joins are used.
* Please use doDelete(Criteria, String, Connection).
*/
- public static void doDelete(Criteria criteria, Connection con)
+ protected void doDelete(Criteria criteria, Connection con)
throws TorqueException
{
Criteria.Criterion criterion
@@ -287,7 +270,7 @@ public abstract class BasePeer
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- public static int doDelete(
+ public int doDelete(
Criteria criteria,
String tableName,
Connection connection)
@@ -331,7 +314,7 @@ public abstract class BasePeer
// }
// };
- Query query = createQuery(criteria);
+ Query query = SqlBuilder.buildQuery(criteria);
query.setType(Query.Type.DELETE);
query.getFromClause().clear();
@@ -405,7 +388,7 @@ public abstract class BasePeer
*
* @throws TorqueException if a database error occurs.
*/
- public static ObjectKey doInsert(ColumnValues insertValues)
+ public ObjectKey doInsert(ColumnValues insertValues)
throws TorqueException
{
String databaseName;
@@ -462,7 +445,7 @@ public abstract class BasePeer
*
* @throws TorqueException if a database error occurs.
*/
- public static ObjectKey doInsert(
+ public ObjectKey doInsert(
ColumnValues insertValues,
Connection connection)
throws TorqueException
@@ -514,7 +497,7 @@ public abstract class BasePeer
}
String fullTableName = SqlBuilder.getFullTableName(
- tableMap.getName(),
+ tableMap.getName(),
dbMap.getName());
StringBuilder query = new StringBuilder("INSERT INTO ")
.append(fullTableName)
@@ -616,7 +599,7 @@ public abstract class BasePeer
* @return A simple Key representing the new Id value
* @throws TorqueException Possible errors get wrapped in here.
*/
- private static SimpleKey getId(
+ private SimpleKey getId(
ColumnMap pk,
IdGenerator keyGen,
Connection con,
@@ -655,7 +638,7 @@ public abstract class BasePeer
* @return the SQL query for display
* @exception TorqueException Trouble creating the query string.
*/
- static String createQueryDisplayString(Criteria criteria)
+ String createQueryDisplayString(Criteria criteria)
throws TorqueException
{
Query query = SqlBuilder.buildQuery(criteria);
@@ -663,22 +646,6 @@ public abstract class BasePeer
}
/**
- * Method to create an SQL query based on values in a Criteria. Note that
- * final manipulation of the limit and offset are performed when the query
- * is actually executed.
- *
- * @param criteria A Criteria.
- * @return the sql query
- * @exception TorqueException Trouble creating the query string.
- */
- // TODO: remove and replace occurances with implementation
- static Query createQuery(Criteria criteria)
- throws TorqueException
- {
- return SqlBuilder.buildQuery(criteria);
- }
-
- /**
* Selects rows from a database an maps them to objects.
*
* @param criteria A Criteria specifying the records to select, not null.
@@ -691,7 +658,7 @@ public abstract class BasePeer
*
* @throws TorqueException if querying the database fails.
*/
- public static <T> List<T> doSelect(
+ public <T> List<T> doSelect(
Criteria criteria,
RecordMapper<T> mapper,
TableMap defaultTableMap)
@@ -738,7 +705,7 @@ public abstract class BasePeer
*
* @throws TorqueException if querying the database fails.
*/
- public static <T> List<T> doSelect(
+ public <T> List<T> doSelect(
String query,
RecordMapper<T> mapper,
TableMap defaultTableMap,
@@ -789,7 +756,7 @@ public abstract class BasePeer
*
* @throws TorqueException if querying the database fails.
*/
- public static <T> List<T> doSelect(
+ public <T> List<T> doSelect(
String query,
RecordMapper<T> mapper,
TableMap defaultTableMap,
@@ -866,7 +833,7 @@ public abstract class BasePeer
// * @throws TorqueException Any exceptions caught during processing will be
// * rethrown wrapped into a TorqueException.
// */
-// private static ColumnMap getPrimaryKey(Criteria criteria)
+// privateColumnMap getPrimaryKey(Criteria criteria)
// throws TorqueException
// {
// // Assume all the keys are for the same table.
@@ -922,7 +889,7 @@ public abstract class BasePeer
// * @throws TorqueException Any exceptions caught during processing will be
// * rethrown wrapped into a TorqueException.
// */
-// public static int doUpdate(Criteria updateValues) throws TorqueException
+// publicint doUpdate(Criteria updateValues) throws TorqueException
// {
// Connection connection = null;
// try
@@ -966,7 +933,7 @@ public abstract class BasePeer
// * @throws TorqueException Any exceptions caught during processing will be
// * rethrown wrapped into a TorqueException.
// */
-// public static int doUpdate(Criteria updateValues, Connection con)
+// publicint doUpdate(Criteria updateValues, Connection con)
// throws TorqueException
// {
// ColumnMap pk = getPrimaryKey(updateValues);
@@ -1000,7 +967,7 @@ public abstract class BasePeer
// *
// * @throws TorqueException if updating fails.
// */
-// public static void doUpdate(
+// publicvoid doUpdate(
// Criteria selectCriteria,
// Criteria updateValues)
// throws TorqueException
@@ -1035,7 +1002,7 @@ public abstract class BasePeer
// *
// * @throws TorqueException if updating fails.
// */
-// public static int doUpdate(
+// publicint doUpdate(
// Criteria criteria,
// Criteria updateValues,
// Connection connection)
@@ -1128,7 +1095,7 @@ public abstract class BasePeer
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- public static int doUpdate(ColumnValues updateValues)
+ public int doUpdate(ColumnValues updateValues)
throws TorqueException
{
String databaseName;
@@ -1191,7 +1158,7 @@ public abstract class BasePeer
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- public static int doUpdate(
+ public int doUpdate(
ColumnValues updateValues,
Connection connection)
throws TorqueException
@@ -1226,7 +1193,7 @@ public abstract class BasePeer
*
* @throws TorqueException if updating fails.
*/
- public static int doUpdate(
+ public int doUpdate(
Criteria selectCriteria,
ColumnValues updateValues)
throws TorqueException
@@ -1276,13 +1243,13 @@ public abstract class BasePeer
*
* @throws TorqueException if updating fails.
*/
- public static int doUpdate(
+ public int doUpdate(
Criteria criteria,
ColumnValues updateValues,
Connection connection)
throws TorqueException
{
- Query query = createQuery(criteria);
+ Query query = SqlBuilder.buildQuery(criteria);
query.setType(Query.Type.UPDATE);
query.getFromClause().clear();
@@ -1376,7 +1343,7 @@ public abstract class BasePeer
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- public static int executeStatement(String statementString) throws TorqueException
+ public int executeStatement(String statementString) throws TorqueException
{
return executeStatement(statementString, Torque.getDefaultDB());
}
@@ -1392,7 +1359,7 @@ public abstract class BasePeer
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- public static int executeStatement(String statementString, String dbName)
+ public int executeStatement(String statementString, String dbName)
throws TorqueException
{
Connection con = null;
@@ -1420,7 +1387,7 @@ public abstract class BasePeer
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- public static int executeStatement(String statementString, Connection con)
+ public int executeStatement(String statementString, Connection con)
throws TorqueException
{
int rowCount = -1;
@@ -1452,23 +1419,6 @@ public abstract class BasePeer
}
/**
- * This method returns the MapBuilder specified in the name
- * parameter. You should pass in the full path to the class, ie:
- * org.apache.torque.util.db.map.TurbineMapBuilder. The
- * MapBuilder instances are cached in the TorqueInstance for speed.
- *
- * @param name name of the MapBuilder
- * @return A MapBuilder, not null
- * @throws TorqueException if the Map Builder cannot be instantiated
- * @deprecated Use Torque.getMapBuilder(name) instead
- */
- public static MapBuilder getMapBuilder(String name)
- throws TorqueException
- {
- return Torque.getMapBuilder(name);
- }
-
- /**
* Performs a SQL <code>select</code> using a PreparedStatement.
*
* @param criteria A Criteria specifying the records to select, not null.
@@ -1482,7 +1432,7 @@ public abstract class BasePeer
* @return The results of the query, not null.
* @throws TorqueException Error performing database query.
*/
- public static <T> List<T> doSelect(
+ public <T> List<T> doSelect(
Criteria criteria,
RecordMapper<T> mapper,
TableMap defaultTableMap,
@@ -1619,8 +1569,8 @@ public abstract class BasePeer
}
}
- private static void setPreparedStatementReplacements(
- PreparedStatement statement,
+ private void setPreparedStatementReplacements(
+ PreparedStatement statement,
List<Object> replacements,
int offset)
throws SQLException
@@ -1638,7 +1588,7 @@ public abstract class BasePeer
}
else if (param instanceof java.util.Date)
{
- // TODO change to timestamp
+ // TODO change to timestamp
java.sql.Date sqlDate = new java.sql.Date(
((java.util.Date) param).getTime());
statement.setDate(i, sqlDate);
@@ -1687,7 +1637,7 @@ public abstract class BasePeer
* @throws TorqueException if the database map for the criteria cannot be
* retrieved.
*/
- public static void correctBooleans(
+ public void correctBooleans(
Criteria criteria,
TableMap defaultTableMap)
throws TorqueException
@@ -1699,7 +1649,7 @@ public abstract class BasePeer
}
}
- private static void correctBooleans(
+ private void correctBooleans(
Criteria criteria,
Criteria.Criterion criterion,
TableMap defaultTableMap)
@@ -1770,7 +1720,7 @@ public abstract class BasePeer
* @param trueValue the value by which Boolean.TRUE should be replaced.
* @param falseValue the value by which Boolean.FALSE should be replaced.
*/
- private static void replaceBooleanValues(
+ private void replaceBooleanValues(
Criteria.Criterion criterion,
Object trueValue,
Object falseValue)
@@ -1810,7 +1760,7 @@ public abstract class BasePeer
* @throws TorqueException if the database map for the criteria cannot be
* retrieved.
*/
- public static void correctBooleans(
+ public void correctBooleans(
ColumnValues columnValues)
throws TorqueException
{
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=1103171&r1=1103170&r2=1103171&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 Sat May 14 17:34:23 2011
@@ -37,6 +37,7 @@ import org.apache.commons.logging.LogFac
import org.apache.torque.Torque;
import org.apache.torque.TorqueException;
import org.apache.torque.om.mapper.RecordMapper;
+import org.apache.torque.sql.SqlBuilder;
/**
* This class can be used to retrieve a large result set from a database query.
@@ -632,7 +633,7 @@ public class LargeSelect<T> implements R
*/
BasePeer.correctBooleans(criteria, null);
- String query = BasePeer.createQuery(criteria).toString();
+ String query = SqlBuilder.buildQuery(criteria).toString();
// Get a connection to the db.
conn = Torque.getConnection(dbName);
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=1103171&r1=1103170&r2=1103171&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 Sat May 14 17:34:23 2011
@@ -36,6 +36,7 @@ import org.apache.commons.logging.LogFac
import org.apache.torque.TorqueException;
import org.apache.torque.om.mapper.ObjectListMapper;
import org.apache.torque.om.mapper.RecordMapper;
+import org.apache.torque.sql.SqlBuilder;
import org.apache.torque.util.functions.SQLFunction;
/**
@@ -209,7 +210,7 @@ public class SummaryHelper
throws TorqueException
{
Criteria c = buildCriteria(crit);
- String query = BasePeer.createQuery(c).toString();
+ String query = SqlBuilder.buildQuery(c).toString();
RecordMapper<List<Object>> mapper = new ObjectListMapper(resultTypes);
Statement statement = null;
Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/QueryTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/QueryTest.java?rev=1103171&r1=1103170&r2=1103171&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/QueryTest.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/QueryTest.java Sat May 14 17:34:23 2011
@@ -19,11 +19,9 @@ package org.apache.torque.sql;
* under the License.
*/
-import org.apache.torque.sql.Query;
+import org.apache.torque.BaseTestCase;
import org.apache.torque.util.UniqueList;
-import junit.framework.TestCase;
-
/**
* Tests for Query
*
@@ -31,7 +29,7 @@ import junit.framework.TestCase;
* @author <a href="mailto:fischer@seitenbau.de">Thomas Fischer</a>
* @version $Id$
*/
-public class QueryTest extends TestCase
+public class QueryTest extends BaseTestCase
{
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org