diff --git a/src/main/java/world/bentobox/bentobox/database/AbstractDatabaseHandler.java b/src/main/java/world/bentobox/bentobox/database/AbstractDatabaseHandler.java index a33e62c2c..200c17113 100644 --- a/src/main/java/world/bentobox/bentobox/database/AbstractDatabaseHandler.java +++ b/src/main/java/world/bentobox/bentobox/database/AbstractDatabaseHandler.java @@ -148,7 +148,8 @@ public abstract class AbstractDatabaseHandler { public abstract void saveObject(T instance) throws IllegalAccessException, InvocationTargetException, IntrospectionException ; /** - * Deletes the object with the unique id from the database + * Deletes the object with the unique id from the database. If the object does not exist, it will fail silently. + * Use {@link #objectExists(String)} if you need to know if the object is in the database beforehand. * @param instance - object instance */ public abstract void deleteObject(T instance) throws IllegalAccessException, InvocationTargetException, IntrospectionException ; @@ -166,7 +167,8 @@ public abstract class AbstractDatabaseHandler { public abstract void close(); /** - * Attempts to delete the object with the uniqueId + * Attempts to delete the object with the uniqueId. If the object does not exist, it will fail silently. + * Use {@link #objectExists(String)} if you need to know if the object is in the database beforehand. * @param uniqueId - uniqueId of object * @since 1.1 */ diff --git a/src/main/java/world/bentobox/bentobox/database/sql/sqlite/SQLiteDatabaseHandler.java b/src/main/java/world/bentobox/bentobox/database/sql/sqlite/SQLiteDatabaseHandler.java index efa3a3ac5..caf4166b3 100644 --- a/src/main/java/world/bentobox/bentobox/database/sql/sqlite/SQLiteDatabaseHandler.java +++ b/src/main/java/world/bentobox/bentobox/database/sql/sqlite/SQLiteDatabaseHandler.java @@ -51,7 +51,7 @@ public class SQLiteDatabaseHandler extends SQLDatabaseHandler { } Gson gson = getGson(); String toStore = gson.toJson(instance); - processQueue.add(() -> { + processQueue.add(() -> { try (PreparedStatement preparedStatement = getConnection().prepareStatement(getSqlConfig().getSaveObjectSQL())) { preparedStatement.setString(1, toStore); preparedStatement.setString(2, ((DataObject)instance).getUniqueId()); @@ -69,10 +69,7 @@ public class SQLiteDatabaseHandler extends SQLDatabaseHandler { try (PreparedStatement preparedStatement = getConnection().prepareStatement(getSqlConfig().getDeleteObjectSQL())) { // UniqueId must *not* be placed in quotes preparedStatement.setString(1, uniqueId); - int result = preparedStatement.executeUpdate(); - if (result != 1) { - throw new SQLException("Delete did not affect any rows!"); - } + preparedStatement.executeUpdate(); } catch (Exception e) { plugin.logError("Could not delete object " + dataObject.getCanonicalName() + " " + uniqueId + " " + e.getMessage()); }