org.greenrobot.greendao.AbstractDao Java Examples
The following examples show how to use
org.greenrobot.greendao.AbstractDao.
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: DaoSession.java From likequanmintv with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); itemColumnDaoConfig = daoConfigMap.get(ItemColumnDao.class).clone(); itemColumnDaoConfig.initIdentityScope(type); liveCategoryDaoConfig = daoConfigMap.get(LiveCategoryDao.class).clone(); liveCategoryDaoConfig.initIdentityScope(type); playBeanDaoConfig = daoConfigMap.get(PlayBeanDao.class).clone(); playBeanDaoConfig.initIdentityScope(type); itemColumnDao = new ItemColumnDao(itemColumnDaoConfig, this); liveCategoryDao = new LiveCategoryDao(liveCategoryDaoConfig, this); playBeanDao = new PlayBeanDao(playBeanDaoConfig, this); registerDao(ItemColumn.class, itemColumnDao); registerDao(LiveCategory.class, liveCategoryDao); registerDao(PlayBean.class, playBeanDao); }
Example #2
Source File: DaoSession.java From enjoyshop with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); addressDaoConfig = daoConfigMap.get(AddressDao.class).clone(); addressDaoConfig.initIdentityScope(type); userDaoConfig = daoConfigMap.get(UserDao.class).clone(); userDaoConfig.initIdentityScope(type); addressDao = new AddressDao(addressDaoConfig, this); userDao = new UserDao(userDaoConfig, this); registerDao(Address.class, addressDao); registerDao(User.class, userDao); }
Example #3
Source File: DaoSession.java From ClassSchedule with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); courseGroupDaoConfig = daoConfigMap.get(CourseGroupDao.class).clone(); courseGroupDaoConfig.initIdentityScope(type); courseV2DaoConfig = daoConfigMap.get(CourseV2Dao.class).clone(); courseV2DaoConfig.initIdentityScope(type); courseGroupDao = new CourseGroupDao(courseGroupDaoConfig, this); courseV2Dao = new CourseV2Dao(courseV2DaoConfig, this); registerDao(CourseGroup.class, courseGroupDao); registerDao(CourseV2.class, courseV2Dao); }
Example #4
Source File: DaoSession.java From PLDroidShortVideo with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); magicPhotoEntityDaoConfig = daoConfigMap.get(MagicPhotoEntityDao.class).clone(); magicPhotoEntityDaoConfig.initIdentityScope(type); avatarModelDaoConfig = daoConfigMap.get(AvatarModelDao.class).clone(); avatarModelDaoConfig.initIdentityScope(type); magicPhotoEntityDao = new MagicPhotoEntityDao(magicPhotoEntityDaoConfig, this); avatarModelDao = new AvatarModelDao(avatarModelDaoConfig, this); registerDao(MagicPhotoEntity.class, magicPhotoEntityDao); registerDao(AvatarModel.class, avatarModelDao); }
Example #5
Source File: DaoSession.java From Dictionary with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); partDaoConfig = daoConfigMap.get(PartDao.class).clone(); partDaoConfig.initIdentityScope(type); wordBeanDaoConfig = daoConfigMap.get(WordBeanDao.class).clone(); wordBeanDaoConfig.initIdentityScope(type); partDao = new PartDao(partDaoConfig, this); wordBeanDao = new WordBeanDao(wordBeanDaoConfig, this); registerDao(Part.class, partDao); registerDao(WordBean.class, wordBeanDao); }
Example #6
Source File: DaoSession.java From android-orm-benchmark-updated with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); userDaoConfig = daoConfigMap.get(UserDao.class).clone(); userDaoConfig.initIdentityScope(type); messageDaoConfig = daoConfigMap.get(MessageDao.class).clone(); messageDaoConfig.initIdentityScope(type); userDao = new UserDao(userDaoConfig, this); messageDao = new MessageDao(messageDaoConfig, this); registerDao(User.class, userDao); registerDao(Message.class, messageDao); }
Example #7
Source File: DaoSession.java From Android-IM with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); userDaoConfig = daoConfigMap.get(UserDao.class).clone(); userDaoConfig.initIdentityScope(type); searchAddDaoConfig = daoConfigMap.get(SearchAddDao.class).clone(); searchAddDaoConfig.initIdentityScope(type); requestListDaoConfig = daoConfigMap.get(RequestListDao.class).clone(); requestListDaoConfig.initIdentityScope(type); chatLogDaoConfig = daoConfigMap.get(ChatLogDao.class).clone(); chatLogDaoConfig.initIdentityScope(type); userDao = new UserDao(userDaoConfig, this); searchAddDao = new SearchAddDao(searchAddDaoConfig, this); requestListDao = new RequestListDao(requestListDaoConfig, this); chatLogDao = new ChatLogDao(chatLogDaoConfig, this); registerDao(User.class, userDao); registerDao(SearchAdd.class, searchAddDao); registerDao(RequestList.class, requestListDao); registerDao(ChatLog.class, chatLogDao); }
Example #8
Source File: DaoSession.java From KUtils-master with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); isFirstEnterAppDaoConfig = daoConfigMap.get(IsFirstEnterAppDao.class).clone(); isFirstEnterAppDaoConfig.initIdentityScope(type); userDaoConfig = daoConfigMap.get(UserDao.class).clone(); userDaoConfig.initIdentityScope(type); isFirstEnterAppDao = new IsFirstEnterAppDao(isFirstEnterAppDaoConfig, this); userDao = new UserDao(userDaoConfig, this); registerDao(IsFirstEnterApp.class, isFirstEnterAppDao); registerDao(User.class, userDao); }
Example #9
Source File: DaoSession.java From KUtils with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); isFirstEnterAppDaoConfig = daoConfigMap.get(IsFirstEnterAppDao.class).clone(); isFirstEnterAppDaoConfig.initIdentityScope(type); userDaoConfig = daoConfigMap.get(UserDao.class).clone(); userDaoConfig.initIdentityScope(type); isFirstEnterAppDao = new IsFirstEnterAppDao(isFirstEnterAppDaoConfig, this); userDao = new UserDao(userDaoConfig, this); registerDao(IsFirstEnterApp.class, isFirstEnterAppDao); registerDao(User.class, userDao); }
Example #10
Source File: DaoMigrationHelper.java From android-mvp-starter with MIT License | 6 votes |
public void migrate(SQLiteDatabase db, Class<? extends AbstractDao<?, ?>>... daoClasses) { Database database = new StandardDatabase(db); if (DEBUG) { Log.d(TAG, "【Database Version】" + db.getVersion()); Log.d(TAG, "【Generate temp table】start"); } generateTempTables(database, daoClasses); if (DEBUG) { Log.d(TAG, "【Generate temp table】complete"); } dropAllTables(database, true, daoClasses); createAllTables(database, false, daoClasses); if (DEBUG) { Log.d(TAG, "【Restore data】start"); } restoreData(database, daoClasses); if (DEBUG) { Log.d(TAG, "【Restore data】complete"); } }
Example #11
Source File: MyMigrationHelper.java From MiPushFramework with GNU General Public License v3.0 | 6 votes |
public static void migrate(Database database, Class<? extends AbstractDao<?, ?>>... daoClasses) { printLog("【Generate temp table】start"); generateTempTables(database, daoClasses); printLog("【Generate temp table】complete"); com.github.yuweiguocn.library.greendao.MigrationHelper.ReCreateAllTableListener listener = weakListener.get(); if (listener != null) { listener.onDropAllTables(database, true); printLog("【Drop all table by listener】"); listener.onCreateAllTables(database, false); printLog("【Create all table by listener】"); } else { dropAllTables(database, true, daoClasses); createAllTables(database, false, daoClasses); } printLog("【Restore data】start"); restoreData(database, daoClasses); printLog("【Restore data】complete"); }
Example #12
Source File: DaoSession.java From easyweather with MIT License | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); cityEntityDaoConfig = daoConfigMap.get(CityEntityDao.class).clone(); cityEntityDaoConfig.initIdentityScope(type); loveCityEntityDaoConfig = daoConfigMap.get(LoveCityEntityDao.class).clone(); loveCityEntityDaoConfig.initIdentityScope(type); provinceEntityDaoConfig = daoConfigMap.get(ProvinceEntityDao.class).clone(); provinceEntityDaoConfig.initIdentityScope(type); weatherEntityDaoConfig = daoConfigMap.get(WeatherEntityDao.class).clone(); weatherEntityDaoConfig.initIdentityScope(type); cityEntityDao = new CityEntityDao(cityEntityDaoConfig, this); loveCityEntityDao = new LoveCityEntityDao(loveCityEntityDaoConfig, this); provinceEntityDao = new ProvinceEntityDao(provinceEntityDaoConfig, this); weatherEntityDao = new WeatherEntityDao(weatherEntityDaoConfig, this); registerDao(CityEntity.class, cityEntityDao); registerDao(LoveCityEntity.class, loveCityEntityDao); registerDao(ProvinceEntity.class, provinceEntityDao); registerDao(WeatherEntity.class, weatherEntityDao); }
Example #13
Source File: DaoSession.java From Pretty-Zhihu with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); pictureDaoConfig = daoConfigMap.get(PictureDao.class).clone(); pictureDaoConfig.initIdentityScope(type); questionDaoConfig = daoConfigMap.get(QuestionDao.class).clone(); questionDaoConfig.initIdentityScope(type); pictureDao = new PictureDao(pictureDaoConfig, this); questionDao = new QuestionDao(questionDaoConfig, this); registerDao(Picture.class, pictureDao); registerDao(Question.class, questionDao); }
Example #14
Source File: DaoSession.java From MissZzzReader with Apache License 2.0 | 6 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); bookDaoConfig = daoConfigMap.get(BookDao.class).clone(); bookDaoConfig.initIdentityScope(type); chapterDaoConfig = daoConfigMap.get(ChapterDao.class).clone(); chapterDaoConfig.initIdentityScope(type); searchHistoryDaoConfig = daoConfigMap.get(SearchHistoryDao.class).clone(); searchHistoryDaoConfig.initIdentityScope(type); bookDao = new BookDao(bookDaoConfig, this); chapterDao = new ChapterDao(chapterDaoConfig, this); searchHistoryDao = new SearchHistoryDao(searchHistoryDaoConfig, this); registerDao(Book.class, bookDao); registerDao(Chapter.class, chapterDao); registerDao(SearchHistory.class, searchHistoryDao); }
Example #15
Source File: DbMigrationHelper.java From ml-authentication with Apache License 2.0 | 5 votes |
public static void migrate(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) { Log.i(DbMigrationHelper.class.getName(), "migrate"); generateNewTablesIfNotExists(db, daoClasses); generateTempTables(db, daoClasses); dropAllTables(db, true, daoClasses); createAllTables(db, false, daoClasses); restoreData(db, daoClasses); }
Example #16
Source File: GreenDaoUpgrade.java From MissZzzReader with Apache License 2.0 | 5 votes |
@SafeVarargs private final void restoreData(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) { for (Class<? extends AbstractDao<?, ?>> daoClass : daoClasses) { DaoConfig daoConfig = new DaoConfig(db, daoClass); String tableName = daoConfig.tablename; String tempTableName = daoConfig.tablename.concat("_TEMP"); ArrayList<String> properties = new ArrayList<>(); ArrayList<String> propertiesQuery = new ArrayList<>(); for (int j = 0; j < daoConfig.properties.length; j++) { String columnName = daoConfig.properties[j].columnName; if (getColumns(db, tempTableName).contains(columnName)) { properties.add(columnName); propertiesQuery.add(columnName); } else { try { if (getTypeByClass(daoConfig.properties[j].type).equals("INTEGER")) { propertiesQuery.add("0 as " + columnName); properties.add(columnName); } } catch (Exception e) { e.printStackTrace(); } } } String insertTableStringBuilder = "INSERT INTO " + tableName + " (" + TextUtils.join(",", properties) + ") SELECT " + TextUtils.join(",", propertiesQuery) + " FROM " + tempTableName + ";"; db.execSQL(insertTableStringBuilder); db.execSQL("DROP TABLE " + tempTableName); } }
Example #17
Source File: DaoSession.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); userEntityDaoConfig = daoConfigMap.get(UserEntityDao.class).clone(); userEntityDaoConfig.initIdentityScope(type); userEntityDao = new UserEntityDao(userEntityDaoConfig, this); registerDao(UserEntity.class, userEntityDao); }
Example #18
Source File: MigrationHelper.java From Android with MIT License | 5 votes |
public static void migrate(Database database, Class<? extends AbstractDao<?, ?>>... daoClasses) { LogManager.getLogger().d(TAG, "[Generate temp table]start"); generateTempTables(database, daoClasses); LogManager.getLogger().d(TAG, "[Generate temp table]complete"); dropAllTables(database, true, daoClasses); createAllTables(database, false, daoClasses); LogManager.getLogger().d(TAG, "[Restore data]start"); restoreData(database, daoClasses); LogManager.getLogger().d(TAG, "[Restore data]complete"); }
Example #19
Source File: DBManager.java From XposedSmsCode with GNU General Public License v3.0 | 5 votes |
public <T> Observable<T> insertOrReplaceRx(Class<T> entityClass, T entity) { return Observable.fromCallable(() -> { AbstractDao<T, ?> abstractDao = getAbstractDao(entityClass); abstractDao.insertOrReplace(entity); return entity; }); }
Example #20
Source File: DaoSession.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 5 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); userBeanDaoConfig = daoConfigMap.get(UserBeanDao.class).clone(); userBeanDaoConfig.initIdentityScope(type); userBeanDao = new UserBeanDao(userBeanDaoConfig, this); registerDao(UserBean.class, userBeanDao); }
Example #21
Source File: MigrationHelper.java From Android-Architecture with Apache License 2.0 | 5 votes |
@SafeVarargs public final void migrate(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) { generateTempTables(db, daoClasses); DaoMaster.dropAllTables(db, true); DaoMaster.createAllTables(db, false); restoreData(db, daoClasses); }
Example #22
Source File: MigrationHelper.java From FriendBook with GNU General Public License v3.0 | 5 votes |
public static void migrate(SQLiteDatabase db, Class<? extends AbstractDao<?, ?>>... daoClasses) { Database database = new StandardDatabase(db); printLog("【The Old Database Version】" + db.getVersion()); printLog("【Generate temp table】start"); generateTempTables(database, daoClasses); printLog("【Generate temp table】complete"); dropAllTables(database, true, daoClasses); createAllTables(database, false, daoClasses); printLog("【Restore data】start"); restoreData(database, daoClasses); printLog("【Restore data】complete"); }
Example #23
Source File: GreenDaoUpgrade.java From MissZzzReader with Apache License 2.0 | 5 votes |
@SafeVarargs final void migrate(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) { generateTempTables(db, daoClasses); DaoMaster.dropAllTables(db, true); DaoMaster.createAllTables(db, false); restoreData(db, daoClasses); }
Example #24
Source File: MigrationHelper.java From Android with MIT License | 5 votes |
private static void generateTempTables(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) { for (int i = 0; i < daoClasses.length; i++) { String tempTableName = null; DaoConfig daoConfig = new DaoConfig(db, daoClasses[i]); String tableName = daoConfig.tablename; if (!isTableExists(db, false, tableName)) { LogManager.getLogger().d(TAG, "[New Table]" + tableName); continue; } try { tempTableName = daoConfig.tablename.concat("_TEMP"); StringBuilder dropTableStringBuilder = new StringBuilder(); dropTableStringBuilder.append("DROP TABLE IF EXISTS ").append(tempTableName).append(";"); db.execSQL(dropTableStringBuilder.toString()); StringBuilder insertTableStringBuilder = new StringBuilder(); insertTableStringBuilder.append("CREATE TEMPORARY TABLE ").append(tempTableName); insertTableStringBuilder.append(" AS SELECT * FROM ").append(tableName).append(";"); db.execSQL(insertTableStringBuilder.toString()); LogManager.getLogger().d(TAG,"[Table]" + tableName +"\n ---Columns-->"+getColumnsStr(daoConfig)); LogManager.getLogger().d(TAG,"[Generate temp table]" + tempTableName); } catch (SQLException e) { Log.e(TAG, "[Failed to generate temp table]" + tempTableName, e); } } }
Example #25
Source File: DBManager.java From XposedSmsCode with GNU General Public License v3.0 | 5 votes |
public <T> Observable<Boolean> deleteAllRx(Class<T> entityClass) { return Observable.fromCallable(() -> { AbstractDao<T, ?> abstractDao = getAbstractDao(entityClass); abstractDao.deleteAll(); return true; }); }
Example #26
Source File: DaoSession.java From KotlinMVPRxJava2Dagger2GreenDaoRetrofitDemo with Apache License 2.0 | 5 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); myFavoriteDaoConfig = daoConfigMap.get(MyFavoriteDao.class).clone(); myFavoriteDaoConfig.initIdentityScope(type); myFavoriteDao = new MyFavoriteDao(myFavoriteDaoConfig, this); registerDao(MyFavorite.class, myFavoriteDao); }
Example #27
Source File: DBManager.java From XposedSmsCode with GNU General Public License v3.0 | 5 votes |
public <T> Observable<List<T>> deleteInTxRx(Class<T> entityClass, List<T> entities) { return Observable.fromCallable(() -> { AbstractDao<T, ?> abstractDao = getAbstractDao(entityClass); abstractDao.deleteInTx(entities); return entities; }); }
Example #28
Source File: DbMigrationHelper.java From ml-authentication with Apache License 2.0 | 5 votes |
public static void migrate(Database db, Class<? extends AbstractDao<?, ?>>... daoClasses) { Log.i(DbMigrationHelper.class.getName(), "migrate"); generateNewTablesIfNotExists(db, daoClasses); generateTempTables(db, daoClasses); dropAllTables(db, true, daoClasses); createAllTables(db, false, daoClasses); restoreData(db, daoClasses); }
Example #29
Source File: MigrationHelper2.java From HHComicViewer with Apache License 2.0 | 5 votes |
public static void migrate(Database database, Class<? extends AbstractDao<?, ?>>... daoClasses) { printLog("【Generate temp table】start"); generateTempTables(database, daoClasses); printLog("【Generate temp table】complete"); dropAllTables(database, true, daoClasses); createAllTables(database, false, daoClasses); printLog("【Restore data】start"); restoreData(database, daoClasses); printLog("【Restore data】complete"); }
Example #30
Source File: DaoSession.java From Android-Architecture with Apache License 2.0 | 5 votes |
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) { super(db); userModelDaoConfig = daoConfigMap.get(UserModelDao.class).clone(); userModelDaoConfig.initIdentityScope(type); userModelDao = new UserModelDao(userModelDaoConfig, this); registerDao(UserModel.class, userModelDao); }