/** * Executes a {@link Delete} statement. * <p> * Note: Generally speaking, you should prefer to use {@link #delete(Class, long) delete} or * {@link #deleteWhere(Class, Criterion) deleteWhere} for deleting database rows. This is provided as a convenience * in case there exists a non-ORM case where a more traditional SQL delete statement is required. * * @param delete the statement to execute * @return the number of rows deleted on success, -1 on failure */ public int delete(Delete delete) { int result = deleteInternal(delete); if (result > 0) { notifyForTable(DataChangedNotifier.DBOperation.DELETE, null, delete.getTable(), TableModel.NO_ID); } return result; }
/** * Delete all rows matching the given {@link Criterion} * * @param modelClass model class for the table to delete from * @param where the Criterion to match. Note: passing null will delete all rows! * @return the number of deleted rows */ public int deleteWhere(Class<? extends TableModel> modelClass, Criterion where) { Table table = getTable(modelClass); Delete delete = Delete.from(table); if (where != null) { delete.where(where); } int rowsUpdated = deleteInternal(delete); if (rowsUpdated > 0) { notifyForTable(DataChangedNotifier.DBOperation.DELETE, null, table, TableModel.NO_ID); } return rowsUpdated; }
/** * Delete the row with the given row ID * * @param modelClass the model class corresponding to the table to delete from * @param id the row ID of the record * @return true if delete was successful */ public boolean delete(Class<? extends TableModel> modelClass, long id) { Table table = getTable(modelClass); int rowsUpdated = deleteInternal(Delete.from(table).where(table.getRowIdProperty().eq(id))); if (rowsUpdated > 0) { notifyForTable(DataChangedNotifier.DBOperation.DELETE, null, table, id); } return rowsUpdated > 0; }
/** * Executes a {@link Delete} statement. * <p> * Note: Generally speaking, you should prefer to use {@link #delete(Class, long) delete} or * {@link #deleteWhere(Class, Criterion) deleteWhere} for deleting database rows. This is provided as a convenience * in case there exists a non-ORM case where a more traditional SQL delete statement is required. * * @param delete the statement to execute * @return the number of rows deleted on success, -1 on failure */ public int delete(Delete delete) { int result = deleteInternal(delete); if (result > 0) { notifyForTable(DataChangedNotifier.DBOperation.DELETE, null, delete.getTable(), TableModel.NO_ID); } return result; }
/** * Delete all rows matching the given {@link Criterion} * * @param modelClass model class for the table to delete from * @param where the Criterion to match. Note: passing null will delete all rows! * @return the number of deleted rows */ public int deleteWhere(Class<? extends TableModel> modelClass, Criterion where) { Table table = getTable(modelClass); Delete delete = Delete.from(table); if (where != null) { delete.where(where); } int rowsUpdated = deleteInternal(delete); if (rowsUpdated > 0) { notifyForTable(DataChangedNotifier.DBOperation.DELETE, null, table, TableModel.NO_ID); } return rowsUpdated; }
/** * Delete the row with the given row ID * * @param modelClass the model class corresponding to the table to delete from * @param id the row ID of the record * @return true if delete was successful */ public boolean delete(Class<? extends TableModel> modelClass, long id) { Table table = getTable(modelClass); int rowsUpdated = deleteInternal(Delete.from(table).where(table.getRowIdProperty().eq(id))); if (rowsUpdated > 0) { notifyForTable(DataChangedNotifier.DBOperation.DELETE, null, table, id); } return rowsUpdated > 0; }