From 47e97905613795d8a8f6feb517780aeddb8cce19 Mon Sep 17 00:00:00 2001 From: mdb Date: Wed, 23 May 2007 00:54:15 +0000 Subject: [PATCH] Flush our record from the cache if we update just some fields in the record. In the future we'll be extra clever and update just those fields in the cached record if we have one. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2104 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/jdbc/depot/DepotRepository.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/DepotRepository.java b/src/java/com/samskivert/jdbc/depot/DepotRepository.java index 83a24b83..b29a6215 100644 --- a/src/java/com/samskivert/jdbc/depot/DepotRepository.java +++ b/src/java/com/samskivert/jdbc/depot/DepotRepository.java @@ -270,7 +270,9 @@ public class DepotRepository /** * Updates just the specified fields of the supplied persistent object, using its primary key - * to identify the row to be updated. + * to identify the row to be updated. This method currently flushes the associated record from + * the cache, but in the future it should be modified to update the modified fields in the + * cached value iff the record exists in the cache. * * @return the number of rows modified by this action. */ @@ -282,7 +284,8 @@ public class DepotRepository if (key == null) { throw new IllegalArgumentException("Can't update record with null primary key."); } - return _ctx.invoke(new CachingModifier(record, key, key) { + // by passing null as "result" we flush the record from the cache and don't restore it + return _ctx.invoke(new CachingModifier(null, key, key) { public int invoke (Connection conn) throws SQLException { PreparedStatement stmt = marsh.createUpdate(conn, _result, key, modifiedFields); try { @@ -376,7 +379,10 @@ public class DepotRepository } /** - * Updates the specified columns for all persistent objects matching the supplied key. + * Updates the specified columns for all persistent objects matching the supplied key. This + * method currently flushes the associated record from the cache, but in the future it should + * be modified to update the modified fields in the cached value iff the record exists in the + * cache. * * @param type the type of the persistent object to be modified. * @param key the key to match in the update.