You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great if multiple models can be saved in one SQL INSERT.
Batch operation (that already exists in JavaLite) does not provide required functionality (it uses the same single-line INSERT instead).
Example:
class User extends Model {
public User(String name, Integer age){
set("name", prodItem, "age", age);
}
}
...
User c1 = new User("a", 4);
User c2 = new User("b", 5);
User c3 = new User("c", 6);
// suggested method, it executes following SQL INSERT with appropriate query parameters set:
// INSERT INTO users(name, age) VALUES (?,?), (?,?), (?,?) RETURNING id
User.saveMultiple(List.of(c1,c2,c3));
// after the operation, all input models are saved, and have ID set
assert(c1.getId() != null);
assert(c2.getId() != null);
assert(c3.getId() != null);
The text was updated successfully, but these errors were encountered:
Batch operation generate single-row INSERTs, for my example it will be 3 SQL calls:
INSERT INTO users(name, age) VALUES (?,?) RETURNING id
INSERT INTO users(name, age) VALUES (?,?) RETURNING id
INSERT INTO users(name, age) VALUES (?,?) RETURNING id
What I propose is to create multi-row INSERT , like this:
INSERT INTO users(name, age) VALUES (?,?), (?,?), (?,?) RETURNING id
This will give us drastic speed boost on massive INSERT operations.
It would be great if multiple models can be saved in one SQL INSERT.
Batch operation (that already exists in JavaLite) does not provide required functionality (it uses the same single-line INSERT instead).
Example:
The text was updated successfully, but these errors were encountered: