Java Code Examples for com.j256.ormlite.stmt.DeleteBuilder#where()

The following examples show how to use com.j256.ormlite.stmt.DeleteBuilder#where() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NoteManager.java    From ETSMobile-Android2 with Apache License 2.0 6 votes vote down vote up
/**
 * Deletes marks in DB that doesn't exist on API
 *
 * @param
 */
private void deleteExpiredListeDesElementsEvaluation(String id) {
    DatabaseHelper dbHelper = new DatabaseHelper(context);

    try {

        Dao<ListeDesElementsEvaluation, String> listeDesElementsEvaluationDao = dbHelper.getDao(ListeDesElementsEvaluation.class);
        ListeDesElementsEvaluation listeDesElementsEvaluation = listeDesElementsEvaluationDao.queryForId(id);

        if (listeDesElementsEvaluation != null) {
            Dao<ElementEvaluation, String> elementsEvaluationDao = dbHelper.getDao(ElementEvaluation.class);
            DeleteBuilder<ElementEvaluation, String> deleteBuilder = elementsEvaluationDao.deleteBuilder();

            Where where = deleteBuilder.where();
            where.eq("listeDesElementsEvaluation_id", listeDesElementsEvaluation);

            deleteBuilder.delete();
        }

        listeDesElementsEvaluationDao.deleteById(id);


    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
Example 2
Source File: MessageDataManager.java    From q-municate-android with Apache License 2.0 6 votes vote down vote up
public void deleteTempMessages(List<Long> dialogOccupantsIdsList) {
    try {
        DeleteBuilder<Message, Long> deleteBuilder = dao.deleteBuilder();

        Where<Message, Long> where = deleteBuilder.where();
        where.and(
                where.in(DialogOccupant.Column.ID, dialogOccupantsIdsList),
                where.or(
                        where.eq(Message.Column.STATE, State.TEMP_LOCAL),
                        where.eq(Message.Column.STATE, State.TEMP_LOCAL_UNREAD)
                )
        );

        if (deleteBuilder.delete() > 0) {
            //TODO VT need to think how to send IDs to observers
            notifyObserversDeletedById(dialogOccupantsIdsList);
        }
    } catch (SQLException e) {
        ErrorUtils.logError(e);
    }

}
 
Example 3
Source File: OrmLiteDao.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
/**
 * 通过表列名来删除
 *
 * @param map key是列名,value是列对应的值
 * @return
 */
public boolean deleteByColumnName(Map<String, Object> map) throws SQLException {
    DeleteBuilder deleteBuilder = ormLiteDao.deleteBuilder();
    Where where = deleteBuilder.where();
    where.isNotNull("id");
    for (Map.Entry<String, Object> entry : map.entrySet()) {
        where.and().eq(entry.getKey(), entry.getValue());
    }
    return deleteBuilder.delete() > 0;
}