DBFlow
DBFlow copied to clipboard
Retrocompatibility of transactions using TModel of beta6
Hi,
All my models extends from Validable and Validable extends from BaseModel, but with the new way of doing transactions, addAll(Collection
public static void saveModel(Lock lock, Collection<? extends BaseModel> models) {
lock.lock();
try {
if (models != null) {
DatabaseDefinition database = FlowManager.getDatabase(AppDatabase.class);
ProcessModelTransaction<Model> processModelTransaction =
new ProcessModelTransaction.Builder<>(new ProcessModelTransaction.ProcessModel<Model>() {
@Override
public void processModel(Model model) {
}
}).addAll(models).build();
Transaction transaction = database.beginTransactionAsync(processModelTransaction).build();
transaction.execute();
}
} finally {
lock.unlock();
}
}
Also changes Database.NAME ? Is there a lot of improvement inserting objects? We have to insert around 300K elements using tables with ManyToMany and foreignkeys and is a nightmare to do it fast... (Its the initial sync and should be done synchronously)