Java Code Examples for de.greenrobot.dao.query.QueryBuilder#where()

The following examples show how to use de.greenrobot.dao.query.QueryBuilder#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: LuaManager.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
private String getDBLuaFileByVersion(String s)
{
    LuaZipFileDao luazipfiledao = DaoManager.getInstance().getLuaZipFileDao();
    int j = (int)luazipfiledao.count();
    Debug.i("chenee", (new StringBuilder()).append("lzipDao.count:").append(j).toString());
    if (j > 0)
    {
        QueryBuilder querybuilder = luazipfiledao.queryBuilder();
        Property aproperty[] = new Property[1];
        aproperty[0] = de.greenrobot.daobracelet.LuaZipFileDao.Properties.Version;
        querybuilder.orderDesc(aproperty);
        querybuilder.where(de.greenrobot.daobracelet.LuaZipFileDao.Properties.Version.eq(s), new WhereCondition[0]);
        LuaZipFile luazipfile = (LuaZipFile)querybuilder.listLazy().get(0);
        String s1 = luazipfile.getVersion();
        Debug.i("chenee", (new StringBuilder()).append("luaZipFile.version:").append(s1).toString());
        return unzip(luazipfile.getZipFile());
    } else
    {
        Debug.e("chenee", (new StringBuilder()).append("read DB zip failed,version:").append(s).toString());
        return null;
    }
}
 
Example 2
Source File: LuaAction.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public int getCount4(WhereCondition wherecondition, WhereCondition wherecondition1, WhereCondition wherecondition2, WhereCondition wherecondition3)
{
    QueryBuilder querybuilder = DaoManager.getInstance().getLuaListDao().queryBuilder();
    querybuilder.where(wherecondition, new WhereCondition[0]);
    if (wherecondition1 != null)
    {
        querybuilder.where(wherecondition1, new WhereCondition[0]);
    }
    if (wherecondition2 != null)
    {
        querybuilder.where(wherecondition2, new WhereCondition[0]);
    }
    if (wherecondition2 != null)
    {
        querybuilder.where(wherecondition2, new WhereCondition[0]);
    }
    return (int)querybuilder.count();
}
 
Example 3
Source File: LuaAction.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public void delMsg4(WhereCondition wherecondition, WhereCondition wherecondition1, WhereCondition wherecondition2, WhereCondition wherecondition3)
{
    QueryBuilder querybuilder = DaoManager.getInstance().getLuaListDao().queryBuilder();
    querybuilder.where(wherecondition, new WhereCondition[0]);
    if (wherecondition1 != null)
    {
        querybuilder.where(wherecondition1, new WhereCondition[0]);
    }
    if (wherecondition2 != null)
    {
        querybuilder.where(wherecondition2, new WhereCondition[0]);
    }
    if (wherecondition3 != null)
    {
        querybuilder.where(wherecondition3, new WhereCondition[0]);
    }
    querybuilder.buildDelete().executeDeleteWithoutDetachingEntities();
}
 
Example 4
Source File: LuaAction.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public int getCount(WhereCondition wherecondition, WhereCondition wherecondition1)
{
    QueryBuilder querybuilder = DaoManager.getInstance().getLuaListDao().queryBuilder();
    querybuilder.where(wherecondition, new WhereCondition[0]);
    if (wherecondition1 != null)
    {
        querybuilder.where(wherecondition1, new WhereCondition[0]);
    }
    return (int)querybuilder.count();
}
 
Example 5
Source File: UserDao.java    From android-orm-benchmark with Apache License 2.0 5 votes vote down vote up
/** Internal query to resolve the "readers" to-many relationship of Message. */
public List<User> _queryMessage_Readers(Long id) {
    synchronized (this) {
        if (message_ReadersQuery == null) {
            QueryBuilder<User> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.Id.eq(null));
            message_ReadersQuery = queryBuilder.build();
        }
    }
    Query<User> query = message_ReadersQuery.forCurrentThread();
    query.setParameter(0, id);
    return query.list();
}
 
Example 6
Source File: EditFragment.java    From android-sholi with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected LazyList<Item> createList(Context context) {
    QueryBuilder builder = getSession().getItemDao().queryBuilder();
    String constraint = null;
    boolean doShow = false;
    LazyList<Item> list;

    // First build the list to be displayed with loose search.
    if (_newItemEdit != null) {
        constraint = _newItemEdit.getEditableText().toString().trim();
        if (constraint != null && !constraint.isEmpty())
            builder.where(ItemDao.Properties.Name.like('%' + constraint + '%'));
    }
    list = builder.orderAsc(ItemDao.Properties.Name).listLazy();

    // Then check exact equality if necessary. Eventually make a new search.
    if (constraint != null && !constraint.isEmpty()) {
        if (list.isEmpty())
            doShow = true;
        if (list.size() == 1)
            doShow = !list.get(0).getName().equals(constraint);
        else if (list.size() > 1) {
            builder = getSession().getItemDao().queryBuilder();
            doShow = builder.where(ItemDao.Properties.Name.eq(constraint))
                    .buildCount().count() == 0;
        }
    }

    if (_newItemButton != null) {
        int visibility = _newItemButton.getVisibility();
        // Only call setVisibility when necessary.
        if (visibility == View.GONE && doShow)
            _newItemButton.setVisibility(View.VISIBLE);
        else if (visibility == View.VISIBLE && !doShow)
            _newItemButton.setVisibility(View.GONE);
    }
    return list;
}
 
Example 7
Source File: CheckingFragment.java    From android-sholi with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected LazyList<Item> createList(Context context) {
    QueryBuilder builder = getSession().getItemDao().queryBuilder();
    builder.where(builder.or(ItemDao.Properties.Status.eq(Checkable.CHECKED),
            ItemDao.Properties.Status.eq(Checkable.UNCHECKED)));
    builder.orderAsc(ItemDao.Properties.Name);
    return builder.listLazy();
}
 
Example 8
Source File: ChallengeDao.java    From BrainPhaser with GNU General Public License v3.0 5 votes vote down vote up
/** Internal query to resolve the "challenges" to-many relationship of Category. */
public List<Challenge> _queryCategory_Challenges(long categoryId) {
    synchronized (this) {
        if (category_ChallengesQuery == null) {
            QueryBuilder<Challenge> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.CategoryId.eq(null));
            category_ChallengesQuery = queryBuilder.build();
        }
    }
    Query<Challenge> query = category_ChallengesQuery.forCurrentThread();
    query.setParameter(0, categoryId);
    return query.list();
}
 
Example 9
Source File: LuaAction.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
public void delMsg(WhereCondition wherecondition, WhereCondition wherecondition1)
{
    QueryBuilder querybuilder = DaoManager.getInstance().getLuaListDao().queryBuilder();
    querybuilder.where(wherecondition, new WhereCondition[0]);
    if (wherecondition1 != null)
    {
        querybuilder.where(wherecondition1, new WhereCondition[0]);
    }
    querybuilder.buildDelete().executeDeleteWithoutDetachingEntities();
}
 
Example 10
Source File: AddressItemDao.java    From AndroidDatabaseLibraryComparison with MIT License 5 votes vote down vote up
/** Internal query to resolve the "addressItemList" to-many relationship of AddressBook. */
public List<AddressItem> _queryAddressBook_AddressItemList(Long id) {
    synchronized (this) {
        if (addressBook_AddressItemListQuery == null) {
            QueryBuilder<AddressItem> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.Id.eq(null));
            addressBook_AddressItemListQuery = queryBuilder.build();
        }
    }
    Query<AddressItem> query = addressBook_AddressItemListQuery.forCurrentThread();
    query.setParameter(0, id);
    return query.list();
}
 
Example 11
Source File: ContactDao.java    From AndroidDatabaseLibraryComparison with MIT License 5 votes vote down vote up
/** Internal query to resolve the "contactList" to-many relationship of AddressBook. */
public List<Contact> _queryAddressBook_ContactList(Long id) {
    synchronized (this) {
        if (addressBook_ContactListQuery == null) {
            QueryBuilder<Contact> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.Id.eq(null));
            addressBook_ContactListQuery = queryBuilder.build();
        }
    }
    Query<Contact> query = addressBook_ContactListQuery.forCurrentThread();
    query.setParameter(0, id);
    return query.list();
}
 
Example 12
Source File: alloperatorsDao.java    From RxJavaApp with Apache License 2.0 5 votes vote down vote up
/** Internal query to resolve the "alloperatorsList" to-many relationship of operators. */
public List<alloperators> _queryOperators_AlloperatorsList(Long outer_id) {
    synchronized (this) {
        if (operators_AlloperatorsListQuery == null) {
            QueryBuilder<alloperators> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.Outer_id.eq(null));
            operators_AlloperatorsListQuery = queryBuilder.build();
        }
    }
    Query<alloperators> query = operators_AlloperatorsListQuery.forCurrentThread();
    query.setParameter(0, outer_id);
    return query.list();
}
 
Example 13
Source File: AnswerDao.java    From BrainPhaser with GNU General Public License v3.0 5 votes vote down vote up
/** Internal query to resolve the "answers" to-many relationship of Challenge. */
public List<Answer> _queryChallenge_Answers(long challengeId) {
    synchronized (this) {
        if (challenge_AnswersQuery == null) {
            QueryBuilder<Answer> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.ChallengeId.eq(null));
            challenge_AnswersQuery = queryBuilder.build();
        }
    }
    Query<Answer> query = challenge_AnswersQuery.forCurrentThread();
    query.setParameter(0, challengeId);
    return query.list();
}
 
Example 14
Source File: StatisticsDao.java    From BrainPhaser with GNU General Public License v3.0 5 votes vote down vote up
/** Internal query to resolve the "statistics" to-many relationship of User. */
public List<Statistics> _queryUser_Statistics(long userId) {
    synchronized (this) {
        if (user_StatisticsQuery == null) {
            QueryBuilder<Statistics> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.UserId.eq(null));
            user_StatisticsQuery = queryBuilder.build();
        }
    }
    Query<Statistics> query = user_StatisticsQuery.forCurrentThread();
    query.setParameter(0, userId);
    return query.list();
}
 
Example 15
Source File: CompletionDao.java    From BrainPhaser with GNU General Public License v3.0 5 votes vote down vote up
/** Internal query to resolve the "completions" to-many relationship of User. */
public List<Completion> _queryUser_Completions(long userId) {
    synchronized (this) {
        if (user_CompletionsQuery == null) {
            QueryBuilder<Completion> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.UserId.eq(null));
            user_CompletionsQuery = queryBuilder.build();
        }
    }
    Query<Completion> query = user_CompletionsQuery.forCurrentThread();
    query.setParameter(0, userId);
    return query.list();
}
 
Example 16
Source File: LuaAction.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void queryWhere(QueryBuilder querybuilder, WhereCondition wherecondition)
{
    querybuilder.where(wherecondition, new WhereCondition[0]);
}
 
Example 17
Source File: GreenDaoUtils.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public static QueryBuilder getQueryBuilder(AbstractDao dao, WhereCondition cond, WhereCondition... condmore) {
    setIfLog();
    QueryBuilder qb = dao.queryBuilder();
    qb.where(cond, condmore);
    return qb;
}
 
Example 18
Source File: GreenDaoUtils.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public static QueryBuilder getQueryBuilder(AbstractDao dao, WhereCondition cond, WhereCondition... condmore) {
    setIfLog();
    QueryBuilder qb = dao.queryBuilder();
    qb.where(cond, condmore);
    return qb;
}
 
Example 19
Source File: GreenDaoUtils.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public static QueryBuilder getQueryBuilder(AbstractDao dao, WhereCondition cond, WhereCondition... condmore) {
    setIfLog();
    QueryBuilder qb = dao.queryBuilder();
    qb.where(cond, condmore);
    return qb;
}