Author: tfischer
Date: Sat Oct 30 03:55:55 2010
New Revision: 1028982
URL: http://svn.apache.org/viewvc?rev=1028982&view=rev
Log:
remove commented code (doInsert(Criteria) was replaced by
doInsert(ColumnValues))
Modified:
db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
Modified:
db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java?rev=1028982&r1=1028981&r2=1028982&view=diff
==============================================================================
---
db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
(original)
+++
db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
Sat Oct 30 03:55:55 2010
@@ -373,201 +373,6 @@ public abstract class BasePeer
}
/**
-// * Method to perform inserts based on values and keys in a
-// * Criteria.
-// * <p>
-// * If the primary key is auto incremented the data in Criteria
-// * will be inserted and the auto increment value will be returned.
-// * <p>
-// * If the primary key is included in Criteria then that value will
-// * be used to insert the row.
-// * <p>
-// * If no primary key is included in Criteria then we will try to
-// * figure out the primary key from the database map and insert the
-// * row with the next available id using util.db.IDBroker.
-// * <p>
-// * If no primary key is defined for the table the values will be
-// * inserted as specified in Criteria and -1 will be returned.
-// *
-// * @param criteria Object containing values to insert.
-// * @return An Object which is the id of the row that was inserted
-// * (if the table has a primary key) or null (if the table does not
-// * have a primary key).
-// * @throws TorqueException Any exceptions caught during processing will
be
-// * rethrown wrapped into a TorqueException.
-// */
-// public static ObjectKey doInsert(Criteria criteria) throws
TorqueException
-// {
-// Connection connection = null;
-// try
-// {
-// connection = Transaction.beginOptional(
-// criteria.getDbName(),
-// criteria.isUseTransaction());
-// ObjectKey id = doInsert(criteria, connection);
-// Transaction.commit(connection);
-// connection = null;
-// return id;
-// }
-// finally
-// {
-// if (connection != null)
-// {
-// Transaction.safeRollback(connection);
-// }
-// }
-// }
-//
-// /**
-// * Method to perform inserts based on values and keys in a
-// * Criteria.
-// * <p>
-// * If the primary key is auto incremented the data in Criteria
-// * will be inserted and the auto increment value will be returned.
-// * <p>
-// * If the primary key is included in Criteria then that value will
-// * be used to insert the row.
-// * <p>
-// * If no primary key is included in Criteria then we will try to
-// * figure out the primary key from the database map and insert the
-// * row with the next available id using util.db.IDBroker.
-// * <p>
-// * If no primary key is defined for the table the values will be
-// * inserted as specified in Criteria and null will be returned.
-// *
-// * @param criteria Object containing values to insert.
-// * @param con A Connection.
-// * @return An Object which is the id of the row that was inserted
-// * (if the table has a primary key) or null (if the table does not
-// * have a primary key).
-// * @throws TorqueException Any exceptions caught during processing will
be
-// * rethrown wrapped into a TorqueException.
-// */
-// public static ObjectKey doInsert(Criteria criteria, Connection con)
-// throws TorqueException
-// {
-// SimpleKey id = null;
-//
-// // Get the table name and method for determining the primary
-// // key value.
-// String table = null;
-// Iterator<?> keys = criteria.keySet().iterator();
-// if (keys.hasNext())
-// {
-// table = criteria.getTableName((String) keys.next());
-// }
-// else
-// {
-// throw new TorqueException("Database insert attempted without "
-// + "anything specified to insert");
-// }
-//
-// String dbName = criteria.getDbName();
-// Database database = Torque.getDatabase(dbName);
-// DatabaseMap dbMap = database.getDatabaseMap();
-// TableMap tableMap = dbMap.getTable(table);
-// Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
-// IdGenerator keyGen
-// = database.getIdGenerator(tableMap.getPrimaryKeyMethod());
-//
-// ColumnMap pk = getPrimaryKey(criteria);
-//
-// // If the keyMethod is SEQUENCE or IDBROKERTABLE, get the id
-// // before the insert.
-// if (keyGen != null && keyGen.isPriorToInsert())
-// {
-// // pk will be null if there is no primary key defined for the
table
-// // we're inserting into.
-// if (pk != null &&
!criteria.containsKey(pk.getFullyQualifiedName()))
-// {
-// id = getId(pk, keyGen, con, keyInfo);
-// criteria.add(pk.getFullyQualifiedName(), id.getValue());
-// }
-// }
-//
-// List<String> columnNames = new ArrayList<String>();
-// List<Object> replacementObjects = new ArrayList<Object>();
-// for (Object updateValueObject : criteria.entrySet())
-// {
-// Map.Entry<?, ?> updateValue = (Map.Entry<?, ?>)
updateValueObject;
-// String columnName = updateValue.getKey().toString();
-// if (columnName.lastIndexOf(".") != -1)
-// {
-// columnName = columnName.substring(
-// columnName.lastIndexOf(".") + 1);
-// }
-// columnNames.add(columnName);
-// replacementObjects.add(
-// ((Criteria.Criterion)
updateValue.getValue()).getValue());
-// }
-//
-// StringBuilder query = new StringBuilder("INSERT INTO ")
-// .append(table)
-// .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 = con.prepareStatement(query.toString());
-// int position = 1;
-// for (Object replacementObject : replacementObjects)
-// {
-// preparedStatement.setObject(position, replacementObject);
-// 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(pk, keyGen, con, keyInfo);
-// }
-//
-// return id;
-// }
-
- /**
* Inserts a record into a database table.
* <p>
* If the primary key is included in Criteria, then that value will
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]