diff --git a/src/java/com/samskivert/depot/DepotRepository.java b/src/java/com/samskivert/depot/DepotRepository.java index 31803b2..83e627f 100644 --- a/src/java/com/samskivert/depot/DepotRepository.java +++ b/src/java/com/samskivert/depot/DepotRepository.java @@ -217,10 +217,10 @@ public abstract class DepotRepository * * @throws DatabaseException if any problem is encountered communicating with the database. */ - protected T load (Key key) + protected T load (Key key, QueryClause... clauses) throws DatabaseException { - return load(key.getPersistentClass(), key); + return load(key, CacheStrategy.BEST, clauses); } /** @@ -228,37 +228,12 @@ public abstract class DepotRepository * * @throws DatabaseException if any problem is encountered communicating with the database. */ - protected T load (Class type, Comparable primaryKey, + protected T load (Key key, CacheStrategy strategy, QueryClause... clauses) throws DatabaseException { - clauses = ArrayUtil.append(clauses, _ctx.getMarshaller(type).makePrimaryKey(primaryKey)); - return load(type, clauses); - } - - /** - * Loads the persistent object that matches the specified primary key. - * - * @throws DatabaseException if any problem is encountered communicating with the database. - */ - protected T load (Class type, ColumnExp ix, Comparable val, - QueryClause... clauses) - throws DatabaseException - { - clauses = ArrayUtil.append(clauses, Key.newKey(type, ix, val)); - return load(type, 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, Collection clauses) - throws DatabaseException - { - return load(type, clauses.toArray(new QueryClause[clauses.size()])); + clauses = ArrayUtil.append(clauses, key); + return _ctx.invoke(new FindOneQuery(_ctx, key.getPersistentClass(), strategy, clauses)); } /** @@ -983,8 +958,8 @@ public abstract class DepotRepository DepotMigrationHistoryRecord record; while (true) { // check to see if the migration has already been completed - record = load(DepotMigrationHistoryRecord.class, CacheStrategy.NONE, - DepotMigrationHistoryRecord.getKey(migration.getIdent())); + record = load(DepotMigrationHistoryRecord.getKey(migration.getIdent()), + CacheStrategy.NONE); if (record != null && record.whenCompleted != null) { return; // great, no need to do anything } diff --git a/src/java/com/samskivert/depot/tests/TestRepository.java b/src/java/com/samskivert/depot/tests/TestRepository.java index b2ecfd9..70ec552 100644 --- a/src/java/com/samskivert/depot/tests/TestRepository.java +++ b/src/java/com/samskivert/depot/tests/TestRepository.java @@ -90,7 +90,7 @@ public class TestRepository extends DepotRepository record.numbers = new int[] { 9, 0, 2, 1, 0 }; repo.insert(record); - System.out.println("Record: " + repo.load(TestRecord.class, record.recordId)); + System.out.println("Record: " + repo.load(TestRecord.getKey(record.recordId))); // record.age = 25; // record.name = "Bob"; @@ -100,7 +100,7 @@ public class TestRepository extends DepotRepository repo.updatePartial(TestRecord.class, record.recordId, TestRecord.AGE, 25, TestRecord.NAME, "Bob", TestRecord.NUMBERS, new int[] { 1, 2, 3, 4, 5 }); - System.out.println("Updated " + repo.load(TestRecord.class, record.recordId)); + System.out.println("Updated " + repo.load(TestRecord.getKey(record.recordId))); for (int ii = 2; ii < CREATE_RECORDS; ii++) { record = new TestRecord();