Nixed these two updatePartial() convenience methods because they are

dangerous. The "key" (which identifies the rows you want to change) was
[ColumnExp, Comparable, ...] and the data that you would be changing was
[ColumnExp, Object]. So if you happened to pass a comparable object as the
first value you wanted to change, say:

updatePartial(FooRecord.class, FooRecord.FOO_ID, 5, FooRecord.BAR_ID, 6,
              FooRecord.BAZ, "biffle")

the compiler would think you wanted to use FOO_ID and BAR_ID as a key rather
than FOO_ID as a key and BAR_ID as something to be updated. Either way, it's
not clear what you want, so it should go. Now you have to create a Key():

updatePartial(new Key<FooRecord>(FooRecord.clsas, FooRecord.FOO_ID, 5,
                                 FooRecord.BAR_ID, 6),
              FooRecord.BAZ, "biffle")

or

updatePartial(new Key<FooRecord>(FooRecord.clsas, FooRecord.FOO_ID, 5),
              FooRecord.BAR_ID, 6, FooRecord.BAZ, "biffle")

None of our code was doing this anyway. We were already using Key everywhere or
the (Class, Comparable) method for records with a single column as primary key.
This commit is contained in:
Michael Bayne
2009-03-10 23:30:36 +00:00
parent a9dc596d3e
commit 830e830100
@@ -633,50 +633,6 @@ public abstract class DepotRepository
return updatePartial(_ctx.getMarshaller(type).makePrimaryKey(primaryKey), fieldsValues);
}
/**
* Updates the specified columns for all persistent objects matching the supplied two-column
* primary key.
*
* @param type the type of the persistent object to be modified.
* @param fieldsValues an array containing the columns (as ColumnExp) and the values to be
* assigned, in key, value, key, value, etc. order.
*
* @return the number of rows modified by this action.
*
* @throws DuplicateKeyException if the update attempts to change the key columns of a row to
* values that duplicate another row already in the database.
* @throws DatabaseException if any problem is encountered communicating with the database.
*/
protected <T extends PersistentRecord> int updatePartial (
Class<T> type, ColumnExp ix1, Comparable<?> val1, ColumnExp ix2, Comparable<?> val2,
Object... fieldsValues)
throws DatabaseException
{
return updatePartial(new Key<T>(type, ix1, val1, ix2, val2), fieldsValues);
}
/**
* Updates the specified columns for all persistent objects matching the supplied three-column
* primary key.
*
* @param type the type of the persistent object to be modified.
* @param fieldsValues an array containing the columns (as ColumnExp) and the values to be
* assigned, in key, value, key, value, etc. order.
*
* @return the number of rows modified by this action.
*
* @throws DuplicateKeyException if the update attempts to change the key columns of a row to
* values that duplicate another row already in the database.
* @throws DatabaseException if any problem is encountered communicating with the database.
*/
protected <T extends PersistentRecord> int updatePartial (
Class<T> type, ColumnExp ix1, Comparable<?> val1, ColumnExp ix2, Comparable<?> val2,
ColumnExp ix3, Comparable<?> val3, Object... fieldsValues)
throws DatabaseException
{
return updatePartial(new Key<T>(type, ix1, val1, ix2, val2, ix3, val3), fieldsValues);
}
/**
* Updates the specified columns for all persistent objects matching the supplied key.
*