[Opensource] delete from key info
larry hamel
expresso at codeguild.com
Fri Nov 29 12:37:12 PST 2002
hi,
DBObject.delete() has been modified to implement its old javadoc promise of deleting via primary key info rather than a WHERE clause that tests ALL fields (except in the case where no key fields exists). The new code snippet is below. The javadoc makes this efficiency more clear now.
Now, if you know just the ID of the object, you needn't find() for it to fill up the other fields before deleting it.
larry
----------------------------------------------------------------
sqlCommand.append("DELETE FROM ");
sqlCommand.append(getTargetTable());
if (customWhereClause != null) {
sqlCommand.append(customWhereClause);
} else {
FastStringBuffer fsb = FastStringBuffer.getInstance();
try {
// does this object have key fields?
if ( this.getKeyFieldListIterator().hasNext() ) {
// just use key fields to identify
sqlCommand.append(buildWhereClauseBuffer(false, fsb));
} else {
// use all fields to identify
sqlCommand.append(buildWhereClauseBuffer(true, fsb));
}
} finally {
fsb.release();
}
}
More information about the Opensource
mailing list