diff --git a/src/java/com/samskivert/depot/DepotRepository.java b/src/java/com/samskivert/depot/DepotRepository.java index 753e2f2..fd6f109 100644 --- a/src/java/com/samskivert/depot/DepotRepository.java +++ b/src/java/com/samskivert/depot/DepotRepository.java @@ -271,7 +271,19 @@ public abstract class DepotRepository protected T load (Class type, QueryClause... clauses) throws DatabaseException { - return _ctx.invoke(new FindOneQuery(_ctx, type, clauses)); + return load(type, CacheStrategy.BEST, clauses); + } + + /** + * Loads the first persistent object that matches the supplied query clauses. + * + * @throws DatabaseException if any problem is encountered communicating with the database. + */ + protected T load (Class type, CacheStrategy strategy, + QueryClause... clauses) + throws DatabaseException + { + return _ctx.invoke(new FindOneQuery(_ctx, type, strategy, clauses)); } /** @@ -1063,7 +1075,8 @@ public abstract class DepotRepository DepotMigrationHistoryRecord record; while (true) { // check to see if the migration has already been completed - record = load(DepotMigrationHistoryRecord.class, migration.getIdent()); + record = load(DepotMigrationHistoryRecord.class, CacheStrategy.NONE, + DepotMigrationHistoryRecord.getKey(migration.getIdent())); if (record != null && record.whenCompleted != null) { return; // great, no need to do anything } diff --git a/src/java/com/samskivert/depot/impl/FindOneQuery.java b/src/java/com/samskivert/depot/impl/FindOneQuery.java index a61e8e2..abf54f4 100644 --- a/src/java/com/samskivert/depot/impl/FindOneQuery.java +++ b/src/java/com/samskivert/depot/impl/FindOneQuery.java @@ -45,9 +45,11 @@ import static com.samskivert.depot.Log.log; */ public class FindOneQuery extends Query { - public FindOneQuery (PersistenceContext ctx, Class type, QueryClause[] clauses) + public FindOneQuery (PersistenceContext ctx, Class type, + DepotRepository.CacheStrategy strategy, QueryClause[] clauses) throws DatabaseException { + _strategy = strategy; _marsh = ctx.getMarshaller(type); _select = new SelectClause(type, _marsh.getFieldNames(), clauses); WhereClause where = _select.getWhereClause(); @@ -123,10 +125,14 @@ public class FindOneQuery extends Query protected CacheKey getCacheKey () { + if (_strategy == DepotRepository.CacheStrategy.NONE) { + return null; + } WhereClause where = _select.getWhereClause(); return (where != null && where instanceof CacheKey) ? (CacheKey)where : null; } + protected DepotRepository.CacheStrategy _strategy; protected DepotMarshaller _marsh; protected SelectClause _select; protected SQLBuilder _builder;