Java Code Examples for org.greenrobot.greendao.query.QueryBuilder#where()

The following examples show how to use org.greenrobot.greendao.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: TagListFragment.java    From android-app with GNU General Public License v3.0 6 votes vote down vote up
private QueryBuilder<Tag> getQueryBuilder() {
    QueryBuilder<Tag> qb = tagDao.queryBuilder();

    if (!TextUtils.isEmpty(searchQuery)) {
        qb.where(TagDao.Properties.Label.like("%" + searchQuery + "%"));
    }

    switch (sortOrder) {
        case ASC:
            qb.orderAsc(TagDao.Properties.Label);
            break;

        case DESC:
            qb.orderDesc(TagDao.Properties.Label);
            break;

        default:
            throw new IllegalStateException("Sort order not implemented: " + sortOrder);
    }

    return qb;
}
 
Example 2
Source File: GreenDaoKyHelper.java    From BitkyShop with MIT License 6 votes vote down vote up
/**
 * 在[本地数据库]购物车中插入商品或增加其数量
 *
 * @param c 商品bean
 */
public static void insertOrIncrease(Commodity c) {
  CommodityLocalDao commodityLocalDao = GreenDaoKyHelper.getDaoSession().getCommodityLocalDao();
  QueryBuilder<CommodityLocal> queryBuilder = commodityLocalDao.queryBuilder();
  queryBuilder.where(CommodityLocalDao.Properties.ObjectId.eq(c.getObjectId()));
  List<CommodityLocal> localList = queryBuilder.list();
  KLog.d("查询到的结果数:" + localList.size());
  CommodityLocal commodityLocal =
      new CommodityLocal(null, c.getObjectId(), c.getCategory(), c.getName(), c.getDetails(), 1,
          c.getPrice(), c.getCoverPhotoUrl(), false);
  if (localList.size() >= 1) {
    commodityLocal.setId(localList.get(0).getId());
    commodityLocal.setCartCount(localList.get(0).getCartCount() + 1);
    commodityLocalDao.update(commodityLocal);
  } else {
    commodityLocalDao.insert(commodityLocal);
  }
}
 
Example 3
Source File: PartDao.java    From Dictionary with Apache License 2.0 5 votes vote down vote up
/** Internal query to resolve the "parts" to-many relationship of WordBean. */
public List<Part> _queryWordBean_Parts(Long wordId) {
    synchronized (this) {
        if (wordBean_PartsQuery == null) {
            QueryBuilder<Part> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.WordId.eq(null));
            wordBean_PartsQuery = queryBuilder.build();
        }
    }
    Query<Part> query = wordBean_PartsQuery.forCurrentThread();
    query.setParameter(0, wordId);
    return query.list();
}
 
Example 4
Source File: CookieDbUtil.java    From RxjavaRetrofitDemo-string-master with MIT License 5 votes vote down vote up
public CookieResulte queryCookieBy(String  url) {
    DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
    DaoSession daoSession = daoMaster.newSession();
    CookieResulteDao downInfoDao = daoSession.getCookieResulteDao();
    QueryBuilder<CookieResulte> qb = downInfoDao.queryBuilder();
    qb.where(CookieResulteDao.Properties.Url.eq(url));
    List<CookieResulte> list = qb.list();
    if(list.isEmpty()){
        return null;
    }else{
        return list.get(0);
    }
}
 
Example 5
Source File: PlayBeanDao.java    From likequanmintv with Apache License 2.0 5 votes vote down vote up
/** Internal query to resolve the "list" to-many relationship of LiveCategory. */
public List<PlayBean> _queryLiveCategory_List(Long livecategory_id) {
    synchronized (this) {
        if (liveCategory_ListQuery == null) {
            QueryBuilder<PlayBean> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.Livecategory_id.eq(null));
            liveCategory_ListQuery = queryBuilder.build();
        }
    }
    Query<PlayBean> query = liveCategory_ListQuery.forCurrentThread();
    query.setParameter(0, livecategory_id);
    return query.list();
}
 
Example 6
Source File: DbDwonUtil.java    From RxjavaRetrofitDemo-string-master with MIT License 5 votes vote down vote up
public DownInfo queryDownBy(long Id) {
    DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
    DaoSession daoSession = daoMaster.newSession();
    DownInfoDao downInfoDao = daoSession.getDownInfoDao();
    QueryBuilder<DownInfo> qb = downInfoDao.queryBuilder();
    qb.where(DownInfoDao.Properties.Id.eq(Id));
    List<DownInfo> list = qb.list();
    if(list.isEmpty()){
        return null;
    }else{
        return list.get(0);
    }
}
 
Example 7
Source File: CookieDbUtil.java    From Bailan with Apache License 2.0 5 votes vote down vote up
public CookieResulte queryCookieBy(String  url) {
    DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
    DaoSession daoSession = daoMaster.newSession();
    CookieResulteDao downInfoDao = daoSession.getCookieResulteDao();
    QueryBuilder<CookieResulte> qb = downInfoDao.queryBuilder();
    qb.where(CookieResulteDao.Properties.Url.eq(url));
    List<CookieResulte> list = qb.list();
    if(list.isEmpty()){
        return null;
    }else{
        return list.get(0);
    }
}
 
Example 8
Source File: DbDownUtil.java    From Bailan with Apache License 2.0 5 votes vote down vote up
public DownInfo queryDownBy(long Id) {
    DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
    DaoSession daoSession = daoMaster.newSession();
    DownInfoDao downInfoDao = daoSession.getDownInfoDao();
    QueryBuilder<DownInfo> qb = downInfoDao.queryBuilder();
    qb.where(DownInfoDao.Properties.Id.eq(Id));
    List<DownInfo> list = qb.list();
    if(list.isEmpty()){
        return null;
    }else{
        return list.get(0);
    }
}
 
Example 9
Source File: CourseV2Dao.java    From ClassSchedule with Apache License 2.0 5 votes vote down vote up
/** Internal query to resolve the "cgItems" to-many relationship of CourseGroup. */
public List<CourseV2> _queryCourseGroup_CgItems(Long couCgId) {
    synchronized (this) {
        if (courseGroup_CgItemsQuery == null) {
            QueryBuilder<CourseV2> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.CouCgId.eq(null));
            courseGroup_CgItemsQuery = queryBuilder.build();
        }
    }
    Query<CourseV2> query = courseGroup_CgItemsQuery.forCurrentThread();
    query.setParameter(0, couCgId);
    return query.list();
}
 
Example 10
Source File: ContactHelper.java    From Android with MIT License 5 votes vote down vote up
public void inserRecommendEntity(RecommandFriendEntity entity) {
    QueryBuilder<RecommandFriendEntity> qb = recommandFriendEntityDao.queryBuilder();
    qb.where(RecommandFriendEntityDao.Properties.Pub_key.eq(entity.getPub_key()));
    List<RecommandFriendEntity> list = qb.list();
    if (list.size() > 0) {
        return;
    }
    entity.setStatus(0);
    recommandFriendEntityDao.insert(entity);
}
 
Example 11
Source File: ContactHelper.java    From Android with MIT License 5 votes vote down vote up
/**
 * friend request (one friend one request
 *
 * @param entity
 */
public void inserFriendQuestEntity(FriendRequestEntity entity) {
    QueryBuilder<FriendRequestEntity> qb = friendRequestEntityDao.queryBuilder();
    qb.where(FriendRequestEntityDao.Properties.Pub_key.eq(entity.getPub_key()));
    List<FriendRequestEntity> list = qb.list();
    if (list.size() > 0) {
        deleteRequestEntity(entity.getPub_key());
    }
    friendRequestEntityDao.insertOrReplace(entity);
}
 
Example 12
Source File: DbDwonUtil.java    From Rx-Retrofit with MIT License 5 votes vote down vote up
public DownInfo queryDownBy(long Id) {
    DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
    DaoSession daoSession = daoMaster.newSession();
    DownInfoDao downInfoDao = daoSession.getDownInfoDao();
    QueryBuilder<DownInfo> qb = downInfoDao.queryBuilder();
    qb.where(DownInfoDao.Properties.Id.eq(Id));
    List<DownInfo> list = qb.list();
    if(list.isEmpty()){
        return null;
    }else{
        return list.get(0);
    }
}
 
Example 13
Source File: PictureDao.java    From Pretty-Zhihu with Apache License 2.0 5 votes vote down vote up
/** Internal query to resolve the "pictures" to-many relationship of Question. */
public List<Picture> _queryQuestion_Pictures(int questionId) {
    synchronized (this) {
        if (question_PicturesQuery == null) {
            QueryBuilder<Picture> queryBuilder = queryBuilder();
            queryBuilder.where(Properties.QuestionId.eq(null));
            question_PicturesQuery = queryBuilder.build();
        }
    }
    Query<Picture> query = question_PicturesQuery.forCurrentThread();
    query.setParameter(0, questionId);
    return query.list();
}
 
Example 14
Source File: DbDownUtil.java    From RxjavaRetrofitDemo-master with MIT License 5 votes vote down vote up
public DownInfo queryDownBy(long Id) {
    DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
    DaoSession daoSession = daoMaster.newSession();
    DownInfoDao downInfoDao = daoSession.getDownInfoDao();
    QueryBuilder<DownInfo> qb = downInfoDao.queryBuilder();
    qb.where(DownInfoDao.Properties.Id.eq(Id));
    List<DownInfo> list = qb.list();
    if(list.isEmpty()){
        return null;
    }else{
        return list.get(0);
    }
}
 
Example 15
Source File: DbDownUtil.java    From Bailan with Apache License 2.0 5 votes vote down vote up
public DownInfo queryDownBy(long Id) {
    DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
    DaoSession daoSession = daoMaster.newSession();
    DownInfoDao downInfoDao = daoSession.getDownInfoDao();
    QueryBuilder<DownInfo> qb = downInfoDao.queryBuilder();
    qb.where(DownInfoDao.Properties.Id.eq(Id));
    List<DownInfo> list = qb.list();
    if(list.isEmpty()){
        return null;
    }else{
        return list.get(0);
    }
}
 
Example 16
Source File: CookieDbUtil.java    From RxRetrofit-mvp with MIT License 5 votes vote down vote up
public CookieResulte queryCookieBy(String  url) {
    DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
    DaoSession daoSession = daoMaster.newSession();
    CookieResulteDao downInfoDao = daoSession.getCookieResulteDao();
    QueryBuilder<CookieResulte> qb = downInfoDao.queryBuilder();
    qb.where(CookieResulteDao.Properties.Url.eq(url));
    List<CookieResulte> list = qb.list();
    if(list.isEmpty()){
        return null;
    }else{
        return list.get(0);
    }
}
 
Example 17
Source File: DbDwonUtil.java    From RxRetrofit-mvp with MIT License 5 votes vote down vote up
public DownInfo queryDownBy(long Id) {
    DaoMaster daoMaster = new DaoMaster(getReadableDatabase());
    DaoSession daoSession = daoMaster.newSession();
    DownInfoDao downInfoDao = daoSession.getDownInfoDao();
    QueryBuilder<DownInfo> qb = downInfoDao.queryBuilder();
    qb.where(DownInfoDao.Properties.Id.eq(Id));
    List<DownInfo> list = qb.list();
    if(list.isEmpty()){
        return null;
    }else{
        return list.get(0);
    }
}
 
Example 18
Source File: X8AiLinePointInfoHelper.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public List<X8AiLinePointInfo> getLastItem(int count, int mapType, boolean isFavorites) {
    QueryBuilder<X8AiLinePointInfo> qb = this.lineDao.queryBuilder();
    if (isFavorites) {
        WhereCondition where = Properties.MapType.eq(Integer.valueOf(mapType));
        WhereCondition where1 = Properties.SaveFlag.eq(Integer.valueOf(1));
        qb.where(where, where1).build();
    } else {
        qb.where(Properties.MapType.eq(Integer.valueOf(mapType)), new WhereCondition[0]);
    }
    qb.orderDesc(Properties.Id);
    qb.limit(count);
    return qb.list();
}
 
Example 19
Source File: X8AiLinePointInfoHelper.java    From FimiX8-RE with MIT License 4 votes vote down vote up
public List<X8AiLinePointLatlngInfo> getLatlngByLineId(int mapType, long lineId) {
    QueryBuilder<X8AiLinePointLatlngInfo> qb = this.pointDao.queryBuilder();
    qb.where(X8AiLinePointLatlngInfoDao.Properties.LineId.eq(Long.valueOf(lineId)), new WhereCondition[0]);
    return qb.list();
}
 
Example 20
Source File: X8AiLinePointInfoHelper.java    From FimiX8-RE with MIT License 4 votes vote down vote up
public X8AiLinePointInfo getLineInfoById(long lineId) {
    QueryBuilder<X8AiLinePointInfo> qb = this.lineDao.queryBuilder();
    qb.where(Properties.Id.eq(Long.valueOf(lineId)), new WhereCondition[0]);
    qb.orderDesc(Properties.Id);
    return (X8AiLinePointInfo) qb.list().get(0);
}