diff --git a/src/java/com/samskivert/jdbc/depot/DepotRepository.java b/src/java/com/samskivert/jdbc/depot/DepotRepository.java index 65e5a1a..63b6c3f 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotRepository.java +++ b/src/java/com/samskivert/jdbc/depot/DepotRepository.java @@ -27,6 +27,8 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; +import java.util.Map; import com.samskivert.io.PersistenceException; import com.samskivert.jdbc.ConnectionProvider; @@ -191,6 +193,29 @@ public class DepotRepository }); } + /** + * Updates the specified columns for all persistent objects matching the supplied primary key. + * + * @param type the type of the persistent object to be modified. + * @param primaryKey the primary key to match in the update. + * @param fieldsValues an mapping from the names of the fields/columns ti the values to be + * assigned. + * + * @return the number of rows modified by this action. + */ + protected int updatePartial (Class type, Comparable primaryKey, + HashMap updates) + throws PersistenceException + { + Object[] fieldsValues = new Object[updates.size()*2]; + int idx = 0; + for (Map.Entry entry : updates.entrySet()) { + fieldsValues[idx++] = entry.getKey(); + fieldsValues[idx++] = entry.getValue(); + } + return updatePartial(type, primaryKey, fieldsValues); + } + /** * Updates the specified columns for all persistent objects matching the supplied primary key. *