From 927d8c33360c8b82fb4ac853d5c5f87ac0a92734 Mon Sep 17 00:00:00 2001 From: mjohnson Date: Wed, 21 Mar 2007 23:00:21 +0000 Subject: [PATCH] Added warnedUpdate to the SimpleRepository git-svn-id: https://samskivert.googlecode.com/svn/trunk@2075 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../com/samskivert/jdbc/SimpleRepository.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/java/com/samskivert/jdbc/SimpleRepository.java b/src/java/com/samskivert/jdbc/SimpleRepository.java index 38931157..c5576f1f 100644 --- a/src/java/com/samskivert/jdbc/SimpleRepository.java +++ b/src/java/com/samskivert/jdbc/SimpleRepository.java @@ -3,7 +3,7 @@ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne -// +// // This library is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 2.1 of the License, or @@ -311,6 +311,29 @@ public class SimpleRepository extends Repository }); } + /** + * Executes the supplied update query in this repository, logging a warning + * if the modification count is not equal to the specified count. + */ + protected void warnedUpdate (final String query, final int count) + throws PersistenceException + { + executeUpdate(new Operation() { + public Object invoke (Connection conn, DatabaseLiaison liaison) + throws SQLException, PersistenceException + { + Statement stmt = null; + try { + stmt = conn.createStatement(); + JDBCUtil.warnedUpdate(stmt, query, 1); + } finally { + JDBCUtil.close(stmt); + } + return null; + } + }); + } + /** * Instructs MySQL to perform table maintenance on the specified * table.