Closed Reginer closed 8 years ago
You can do it synchronously.
FlowManager.getDatabase(MyDatabase.class)
.executeTransaction(databaseWrapper -> {
for (MyModel model : models) {
model.save();
}
});
or consider using the save queue thread if it isn't critical that they are saved at exactly that moment.
FlowManager.getDatabase(MyDatabase.class)
.getTransactionManager()
.getSaveQueue()
.addAll(models);
Keep in mind that you can customize the save queue or explicitly flush it after calling addAll
In
FlowManager.getDatabase(MyDatabase.class) .getTransactionManager() .getSaveQueue() .addAll(models); Error is
addAll
(java.util.Collection
The method addAll can not be ArrayList?
You are correct the method in question has an issue with type signature.
It should be:
addAll(final Collection<? extends Model> list)
but it is:
addAll(final Collection<Model> list)
As a workaround for now you can wrap the array list.
so the current .addAll(models)
would become .addAll(new ArrayList<>(models))
One of us should put in a PR that fixes it, although I believe this would be a binary compatibility breaking change which depending on how @agrosner feels may not be released too soon.
You could also for the repo, make the change and request the dependencies though jitpack using your own username and commit hash as the version.
I see,thanks.
Itll be fixed for when 4.0.0-beta1 is released. in develop
now.
DBFlow Version: 3.1.1 Question
Description:
Hey guys。
I want to save a list like 3.0.0beta5
new SaveModelTransaction<>(ProcessModelInfo.withModels(users)).onExecute();
how I should do in 3.1.1 ?
Have a simple code not like
FlowManager.getDatabase(MyDatabase.class) .beginTransactionAsync(new ProcessModelTransaction.Builder<>( new ProcessModelTransaction.ProcessModel() {
@Override
public void processModel(FindContent.FindContentBean content) {
// do work here -- i.e. user.delete() or user.update()
content.save();
}
}).addAll(event.getData()).build()) // add elements (can also handle multiple)
.error(new Transaction.Error() {
@Override
public void onError(Transaction transaction, Throwable error) {
Too cumbersome