de.greenrobot.dao.query.Query Java Examples

The following examples show how to use de.greenrobot.dao.query.Query. 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: DbHelper.java    From octoandroid with GNU General Public License v3.0 6 votes vote down vote up
public PrinterDbEntity getPrinterFromDbByName(String name) {
    Query<PrinterDbEntity> query = mNameSearchQueryMap.get(name);
    if (query == null) {
        query = mPrinterDbEntityDao.queryBuilder()
                .where(PrinterDbEntityDao.Properties.Name.eq(name))
                .build();
        mNameSearchQueryMap.put(name, query);
    }

    try {
        synchronized (sLock) {
            // Need to call forCurrentThread or else it will throw DaoException
            return query.forCurrentThread().unique();
        }
    } catch (DaoException e) {
        return null; // Shouldn't happen
    }
}
 
Example #2
Source File: DbHelper.java    From octoandroid with GNU General Public License v3.0 6 votes vote down vote up
public PrinterDbEntity getPrinterFromDbById(long printerId) {
    Query<PrinterDbEntity> query = mIdSearchQueryMap.get(printerId);
    if (query == null) {
        query = mPrinterDbEntityDao.queryBuilder()
                .where(PrinterDbEntityDao.Properties.Id.eq(printerId))
                .build();
        mIdSearchQueryMap.put(printerId, query);
    }
    try {
        synchronized (sLock) {
            // Need to call forCurrentThread or else it will throw DaoException
            return query.forCurrentThread().unique();
        }
    } catch (DaoException e) {
        return null; // Shouldn't happen
    }
}
 
Example #3
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 #4
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 #5
Source File: RxStats.java    From NBAPlus with Apache License 2.0 5 votes vote down vote up
private static Statistics getCacheStat(String statKind) {
    Statistics statistics=null;
    GreenStatDao greenStatDao = AppService.getDBHelper().getDaoSession().getGreenStatDao();
    Query query = greenStatDao.queryBuilder()
            .where(GreenStatDao.Properties.Statkind.eq(statKind))
            .build();
    // 查询结果以 List 返回
    List<GreenStat> greenStats = query.list();
    if(greenStats!=null&&greenStats.size()>0) {
        statistics = AppService.getGson().fromJson(greenStats.get(0).getStatentity(), Statistics.class);
    }
    return statistics;
}
 
Example #6
Source File: RxNews.java    From NBAPlus with Apache License 2.0 5 votes vote down vote up
private static News getCacheNews(String newsType) {
    News news=null;
    GreenNewsDao greenNewsDao = AppService.getDBHelper().getDaoSession().getGreenNewsDao();
    Query query = greenNewsDao.queryBuilder()
            .where(GreenNewsDao.Properties.Type.eq(newsType))
            .build();
    // 查询结果以 List 返回
    List<GreenNews> greenNewses = query.list();
    if(greenNewses!=null&&greenNewses.size()>0) {
        news = AppService.getGson().fromJson(greenNewses.get(0).getNewslist(), News.class);
    }
    return news;
}
 
Example #7
Source File: DBInterface.java    From sctalk with Apache License 2.0 5 votes vote down vote up
public MessageEntity getMessageByMsgId(int messageId){
    MessageDao dao = openReadableDb().getMessageDao();
    Query query = dao.queryBuilder().where(
            MessageDao.Properties.Id.eq(messageId))
            .build();
    return formatMessage((MessageEntity)query.unique());
}
 
Example #8
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 #9
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 #10
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 #11
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 #12
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 #13
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 #14
Source File: AbstractDao.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public transient Query queryRawCreate(String s, Object aobj[])
{
    return queryRawCreateListArgs(s, Arrays.asList(aobj));
}
 
Example #15
Source File: AbstractDao.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public Query queryRawCreateListArgs(String s, Collection collection)
{
    return Query.internalCreate(this, (new StringBuilder()).append(statements.getSelectAll()).append(s).toString(), collection.toArray());
}
 
Example #16
Source File: AsyncSession.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public AsyncOperation queryList(Query query)
{
    return queryList(query, 0);
}
 
Example #17
Source File: AsyncSession.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public AsyncOperation queryList(Query query, int i)
{
    return enqueueDatabaseOperation(AsyncOperation.OperationType.QueryList, query, i);
}
 
Example #18
Source File: AsyncSession.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public AsyncOperation queryUnique(Query query)
{
    return queryUnique(query, 0);
}
 
Example #19
Source File: AsyncSession.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public AsyncOperation queryUnique(Query query, int i)
{
    return enqueueDatabaseOperation(AsyncOperation.OperationType.QueryUnique, query, i);
}