public static QueryBuilder getQueryBuilder( AbstractDao dao, WhereCondition cond, WhereCondition... condmore) { setIfLog(); QueryBuilder qb = dao.queryBuilder(); qb.where(cond, condmore); return qb; }
/** * Executes the query and returns the result as a list containing all entities loaded into memory. * * @param dao * @param orderProperty * @param whereCondition * @param whereConditions * @return */ public static List getList( AbstractDao dao, Property orderProperty, WhereCondition whereCondition, WhereCondition... whereConditions) { setIfLog(); List indexFavList = dao.queryBuilder().where(whereCondition, whereConditions).orderAsc(orderProperty).list(); return indexFavList; }
/** * Executes the query and returns the result as a list containing all entities loaded into memory. * * @param dao * @param isAsc * @param orderProperty * @return */ public static List getList(AbstractDao dao, boolean isAsc, Property... orderProperty) { setIfLog(); QueryBuilder queryBuilder = dao.queryBuilder(); if (isAsc) { queryBuilder = queryBuilder.orderAsc(orderProperty); } else { queryBuilder = queryBuilder.orderDesc(orderProperty); } List indexFavList = queryBuilder.list(); return indexFavList; }
/** * Deletes all matching entities without detaching them from the identity scope (aka * session/cache). Note that this method may lead to stale entity objects in the session cache. * Stale entities may be returned when loaded by their primary key, but not using queries. * * @param dao * @param cond * @param condmore */ public static void deleteByCondition( AbstractDao dao, WhereCondition cond, WhereCondition... condmore) { setIfLog(); QueryBuilder qb = dao.queryBuilder(); qb.where(cond, condmore).buildDelete().executeDeleteWithoutDetachingEntities(); }
/** * Creates a repeatable Query object based on the given raw SQL where you can pass any WHERE * clause and arguments. * * @param dao * @param queryString * @return */ public static Query query(AbstractDao dao, String queryString) { // queryString="_ID IN " + "(SELECT USER_ID FROM USER_MESSAGE WHERE READ_FLAG = 0)" Query query = dao.queryBuilder().where(new WhereCondition.StringCondition(queryString)).build(); return query; }
/** * @see #getList(de.greenrobot.dao.AbstractDao, de.greenrobot.dao.Property, * de.greenrobot.dao.query.WhereCondition, de.greenrobot.dao.query.WhereCondition...) * @param dao * @return */ public static List getList(AbstractDao dao) { setIfLog(); List indexFavList = dao.queryBuilder().list(); return indexFavList; }