de.greenrobot.dao.query.QueryBuilder Java Examples
The following examples show how to use
de.greenrobot.dao.query.QueryBuilder.
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: PictureCache.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 6 votes |
/** * 根据页码获取缓存数据 * * @param page * @return */ @Override public ArrayList<Picture> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.PictureCache> query = mPictureCacheDao.queryBuilder().where(PictureCacheDao .Properties.Page.eq("" + page)); if (query.list().size() > 0) { return (ArrayList<Picture>) JSONParser.toObject(query.list().get(0).getResult(), new TypeToken<ArrayList<Picture>>() { }.getType()); } else { return new ArrayList<Picture>(); } }
Example #2
Source File: LuaAction.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
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 #3
Source File: PictureCache.java From JianDanRxJava with Apache License 2.0 | 6 votes |
/** * 根据页码获取缓存数据 * * @param page * @return */ @Override public ArrayList<Picture> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.PictureCache> query = mPictureCacheDao.queryBuilder().where(PictureCacheDao .Properties.Page.eq("" + page)); if (query.list().size() > 0) { return (ArrayList<Picture>) JSONParser.toObject(query.list().get(0).getResult(), new TypeToken<ArrayList<Picture>>() { }.getType()); } else { return new ArrayList<>(); } }
Example #4
Source File: PushDbService.java From anetty_client with Apache License 2.0 | 6 votes |
/** * 从数据库中获取设备信息 * * @return */ public Map<String, Device> queryDevicesForMap() { QueryBuilder<Device> qb = this.deviceDao.queryBuilder(); List<Device> list = qb.list(); if (list != null && list.size() > 0) { Map<String, Device> map = new HashMap<String, Device>(); for (Device device : list) { if (device != null) { // 设备从数据库中取出来默认为已经离线 device.setIsOnline(ApplicationContextClient.DEVICE_OFFLINE); map.put(device.getAppPackage(), device); } } return map; } return null; }
Example #5
Source File: FreshNewsCache.java From JianDan_OkHttpWithVolley with Apache License 2.0 | 6 votes |
@Override public ArrayList<FreshNews> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.FreshNewsCache> query = mFreshNewsCacheDao.queryBuilder().where(FreshNewsCacheDao .Properties.Page.eq("" + page)); if (query.list().size() > 0) { try { return FreshNews.parseCache(new JSONArray(query.list().get(0) .getResult())); } catch (JSONException e) { e.printStackTrace(); return new ArrayList<>(); } } else { return new ArrayList<>(); } }
Example #6
Source File: FreshNewsCache.java From JianDanRxJava with Apache License 2.0 | 6 votes |
@Override public ArrayList<FreshNews> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.FreshNewsCache> query = mFreshNewsCacheDao.queryBuilder().where(FreshNewsCacheDao .Properties.Page.eq("" + page)); if (query.list().size() > 0) { try { return FreshNews.parseCache(new JSONArray(query.list().get(0) .getResult())); } catch (JSONException e) { e.printStackTrace(); return new ArrayList<>(); } } else { return new ArrayList<>(); } }
Example #7
Source File: LuaAction.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
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 #8
Source File: FreshNewsCache.java From JianDan_OkHttp with Apache License 2.0 | 6 votes |
@Override public ArrayList<FreshNews> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.FreshNewsCache> query = mFreshNewsCacheDao.queryBuilder().where(FreshNewsCacheDao .Properties.Page.eq("" + page)); if (query.list().size() > 0) { try { return FreshNews.parseCache(new JSONArray(query.list().get(0) .getResult())); } catch (JSONException e) { e.printStackTrace(); return new ArrayList<>(); } } else { return new ArrayList<>(); } }
Example #9
Source File: PictureCache.java From JianDan with Apache License 2.0 | 6 votes |
/** * 根据页码获取缓存数据 * * @param page * @return */ @Override public ArrayList<Picture> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.PictureCache> query = mPictureCacheDao.queryBuilder().where(PictureCacheDao .Properties.Page.eq("" + page)); if (query.list().size() > 0) { return (ArrayList<Picture>) JSONParser.toObject(query.list().get(0).getResult(), new TypeToken<ArrayList<Picture>>() { }.getType()); } else { return new ArrayList<Picture>(); } }
Example #10
Source File: LuaManager.java From MiBandDecompiled with Apache License 2.0 | 6 votes |
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 #11
Source File: FreshNewsCache.java From JianDan with Apache License 2.0 | 6 votes |
@Override public ArrayList<FreshNews> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.FreshNewsCache> query = mFreshNewsCacheDao.queryBuilder().where(FreshNewsCacheDao .Properties.Page.eq("" + page)); if (query.list().size() > 0) { try { return FreshNews.parseCache(new JSONArray(query.list().get(0) .getResult())); } catch (JSONException e) { e.printStackTrace(); return new ArrayList<>(); } } else { return new ArrayList<>(); } }
Example #12
Source File: PictureCache.java From JianDan_OkHttp with Apache License 2.0 | 6 votes |
/** * 根据页码获取缓存数据 * * @param page * @return */ @Override public ArrayList<Picture> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.PictureCache> query = mPictureCacheDao.queryBuilder().where(PictureCacheDao .Properties.Page.eq("" + page)); if (query.list().size() > 0) { return (ArrayList<Picture>) JSONParser.toObject(query.list().get(0).getResult(), new TypeToken<ArrayList<Picture>>() { }.getType()); } else { return new ArrayList<Picture>(); } }
Example #13
Source File: DbUtil.java From WaveHeartRate with Apache License 2.0 | 6 votes |
public static List<HistoryEntity> getTopTen(Context m_Context){ SQLiteDatabase m_Database = null; List<HistoryEntity> result = null; try{ HistoryEntityDao entryDao = getReadDao(m_Context); m_Database = entryDao.getDatabase(); QueryBuilder qb = entryDao.queryBuilder(); // maybe the order is not need,cause the calcuate time of later is always bigger than before. result = qb.orderDesc(HistoryEntityDao.Properties.CalculateTime).limit(LIMITED_RECORD_SIZE).list(); if(result != null){ for(HistoryEntity entity : result){ entity.setStrCalculateTime(CommonUtil.getReadableDateTime(entity.getCalculateTime())); } } }catch(Exception e){ // ignore the exception handler }finally{ if(m_Database != null){ m_Database.close(); m_Database = null; } } return result; }
Example #14
Source File: GreenDaoUtils.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private static void setIfLog() { if (isLog) { QueryBuilder.LOG_SQL = true; QueryBuilder.LOG_VALUES = true; } else { QueryBuilder.LOG_SQL = false; QueryBuilder.LOG_VALUES = false; } }
Example #15
Source File: CheckingFragment.java From android-sholi with GNU General Public License v3.0 | 5 votes |
@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 #16
Source File: GreenDaoUtils.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * 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; }
Example #17
Source File: GreenDaoUtils.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * 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; }
Example #18
Source File: GreenDaoUtils.java From UltimateAndroid with Apache License 2.0 | 5 votes |
private static void setIfLog() { if (isLog) { QueryBuilder.LOG_SQL = true; QueryBuilder.LOG_VALUES = true; } else { QueryBuilder.LOG_SQL = false; QueryBuilder.LOG_VALUES = false; } }
Example #19
Source File: VideoCache.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
@Override public ArrayList<Video> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.VideoCache> query = mVideoCacheDao.queryBuilder().where(VideoCacheDao.Properties.Page.eq("" + page)); if (query.list().size() > 0) { return (ArrayList<Video>) JSONParser.toObject(query.list().get(0).getResult(), new TypeToken<ArrayList<Video>>() { }.getType()); } else { return new ArrayList<>(); } }
Example #20
Source File: JokeCache.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
@Override public ArrayList<Joke> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.JokeCache> query = mJokeCacheDao.queryBuilder().where(JokeCacheDao.Properties.Page.eq("" + page)); if (query.list().size() > 0) { return (ArrayList<Joke>) JSONParser.toObject(query.list().get(0).getResult(), new TypeToken<ArrayList<Joke>>() { }.getType()); } else { return new ArrayList<>(); } }
Example #21
Source File: SisterCache.java From JianDan_OkHttp with Apache License 2.0 | 5 votes |
@Override public ArrayList<Picture> getCacheByPage(int page) { QueryBuilder<com.socks.greendao.SisterCache> query = mPictureCacheDao.queryBuilder().where(SisterCacheDao .Properties.Page.eq(Integer.toString(page))); if (query.list().size() > 0) { return (ArrayList<Picture>) JSONParser.toObject(query.list().get(0).getResult(), new TypeToken<ArrayList<Picture>>() { }.getType()); } else { return new ArrayList<>(); } }
Example #22
Source File: LuaAction.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
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 #23
Source File: EditFragment.java From android-sholi with GNU General Public License v3.0 | 5 votes |
@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 #24
Source File: DBInterface.java From sctalk with Apache License 2.0 | 5 votes |
public void deleteMessageByMsgId(int msgId){ if(msgId <= 0){ return; } MessageDao messageDao = openWritableDb().getMessageDao(); QueryBuilder<MessageEntity> qb = openWritableDb().getMessageDao().queryBuilder(); DeleteQuery<MessageEntity> bd = qb.where(MessageDao.Properties.MsgId.eq(msgId)).buildDelete(); bd.executeDeleteWithoutDetachingEntities(); }
Example #25
Source File: GreenDaoUtils.java From UltimateAndroid with Apache License 2.0 | 5 votes |
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; }
Example #26
Source File: LuaListAdapter.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public void refreshList() { LuaListDao lualistdao = DaoManager.getInstance().getLuaListDao(); String s = getDate(); QueryBuilder querybuilder = lualistdao.queryBuilder().where(de.greenrobot.daobracelet.LuaListDao.Properties.Date.eq(s), new WhereCondition[0]).where(de.greenrobot.daobracelet.LuaListDao.Properties.Type.notEq("8888"), new WhereCondition[0]).where(de.greenrobot.daobracelet.LuaListDao.Properties.Type.notEq("9999"), new WhereCondition[0]); Property aproperty[] = new Property[1]; aproperty[0] = de.greenrobot.daobracelet.LuaListDao.Properties.Id; List list = querybuilder.orderDesc(aproperty).list(); Collections.sort(list, new MyComparator()); setList(list); }
Example #27
Source File: LuaManager.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private String getLatestDBLuaFile() { 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); LuaZipFile luazipfile = (LuaZipFile)querybuilder.listLazy().get(0); String s = luazipfile.getVersion(); String s1 = getDefaultLuaFileVersion(); if (s.compareTo(s1) <= 0) { Debug.e("chenee", (new StringBuilder()).append("version compare failed: version:").append(s).append(" default version is:").append(s1).toString()); return null; } else { Debug.i("chenee", (new StringBuilder()).append("use latest script, version:").append(s).append(" (default version is:").append(s1).append(")").toString()); return unzip(luazipfile.getZipFile()); } } else { Debug.e("chenee", "read DB zip file failed"); return null; } }
Example #28
Source File: LuaAction.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
public LuaList queryLastItem(QueryBuilder querybuilder) { Property aproperty[] = new Property[1]; aproperty[0] = de.greenrobot.daobracelet.LuaListDao.Properties.Id; querybuilder.orderDesc(aproperty); List list = querybuilder.list(); if (list.size() > 0) { return (LuaList)list.get(0); } else { return null; } }
Example #29
Source File: LuaAction.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
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 #30
Source File: UserDao.java From android-orm-benchmark with Apache License 2.0 | 5 votes |
/** 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(); }