DBFlow icon indicating copy to clipboard operation
DBFlow copied to clipboard

Retrocompatibility of transactions using TModel of beta6

Open arturonaredo opened this issue 10 years ago • 0 comments

Hi,

All my models extends from Validable and Validable extends from BaseModel, but with the new way of doing transactions, addAll(Collection), this objects are not valid, seems so:

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)

arturonaredo avatar Apr 17 '16 17:04 arturonaredo