From 39936ac7d47bdba16b9fe0dbed1010c4ab285563 Mon Sep 17 00:00:00 2001 From: mdb Date: Mon, 1 Aug 2005 21:18:27 +0000 Subject: [PATCH] Added a loadByExample() variant that takes a field mask. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1682 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/jdbc/JORARepository.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/projects/samskivert/src/java/com/samskivert/jdbc/JORARepository.java b/projects/samskivert/src/java/com/samskivert/jdbc/JORARepository.java index 5523bff7..51d5227f 100644 --- a/projects/samskivert/src/java/com/samskivert/jdbc/JORARepository.java +++ b/projects/samskivert/src/java/com/samskivert/jdbc/JORARepository.java @@ -122,6 +122,24 @@ public abstract class JORARepository extends SimpleRepository }); } + /** + * Loads a single object from the specified table that matches the + * supplied example. Note: the query should match one or zero + * records, not more. + */ + protected Object loadByExample ( + final Table table, final FieldMask mask, final Object example) + throws PersistenceException + { + return execute(new Operation() { + public Object invoke (Connection conn, DatabaseLiaison liaison) + throws SQLException, PersistenceException + { + return table.queryByExample(example, mask).next(); + } + }); + } + /** * First attempts to update the supplied object and if that modifies * zero rows, inserts the object into the specified table. The table