Java Code Examples for com.raizlabs.android.dbflow.structure.ModelAdapter#storeModelInCache()
The following examples show how to use
com.raizlabs.android.dbflow.structure.ModelAdapter#storeModelInCache() .
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: CacheableListModelSaver.java From Meteorite with Apache License 2.0 | 6 votes |
@Override public synchronized void saveAll(@NonNull Collection<TModel> tableCollection, @NonNull DatabaseWrapper wrapper) { // skip if empty. if (tableCollection.isEmpty()) { return; } ModelSaver<TModel> modelSaver = getModelSaver(); ModelAdapter<TModel> modelAdapter = modelSaver.getModelAdapter(); DatabaseStatement statement = modelAdapter.getInsertStatement(wrapper); DatabaseStatement updateStatement = modelAdapter.getUpdateStatement(wrapper); try { for (TModel model : tableCollection) { if (modelSaver.save(model, wrapper, statement, updateStatement)) { modelAdapter.storeModelInCache(model); } } } finally { updateStatement.close(); statement.close(); } }
Example 2
Source File: CacheableListModelSaver.java From Meteorite with Apache License 2.0 | 6 votes |
@Override public synchronized void insertAll(@NonNull Collection<TModel> tableCollection, @NonNull DatabaseWrapper wrapper) { // skip if empty. if (tableCollection.isEmpty()) { return; } ModelSaver<TModel> modelSaver = getModelSaver(); ModelAdapter<TModel> modelAdapter = modelSaver.getModelAdapter(); DatabaseStatement statement = modelAdapter.getInsertStatement(wrapper); try { for (TModel model : tableCollection) { if (modelSaver.insert(model, statement, wrapper) > 0) { modelAdapter.storeModelInCache(model); } } } finally { statement.close(); } }
Example 3
Source File: CacheableListModelSaver.java From Meteorite with Apache License 2.0 | 6 votes |
@Override public synchronized void updateAll(@NonNull Collection<TModel> tableCollection, @NonNull DatabaseWrapper wrapper) { // skip if empty. if (tableCollection.isEmpty()) { return; } ModelSaver<TModel> modelSaver = getModelSaver(); ModelAdapter<TModel> modelAdapter = modelSaver.getModelAdapter(); DatabaseStatement statement = modelAdapter.getUpdateStatement(wrapper); try { for (TModel model : tableCollection) { if (modelSaver.update(model, wrapper, statement)) { modelAdapter.storeModelInCache(model); } } } finally { statement.close(); } }