manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.42k stars 125 forks source link

manifold-sql: support batch processing #607

Closed rsmckinney closed 4 months ago

rsmckinney commented 4 months ago

manifold-sql should provide a type-safe, well integrated API for batch processing.

Proposal:

Use addBatchChange to batch many invocations of the same parameterized statement as one database call.

List<String> countries = loadCountries)();
. . .
Sakila.addBatchChange(ctx -> {
  for(String country: countries) {
    "[.sql/] INSERT INTO country (country) VALUES (:name)".execute(ctx, country);
  }
}  
. . .
Sakila.commit();

Use addBatchChange to batch many non-parameterized SQL statements as one database call.

Sakila.addBatchChange(ctx -> {
    "[.sql/] INSERT INTO country (country) VALUES ('Canada')".execute(ctx);
    "[.sql/] INSERT INTO country (country) VALUES ('Mexico')".execute(ctx);
    "[.sql/] INSERT INTO country (country) VALUES ('Belize')".execute(ctx);
    . . .
  }
}
. . .
Sakila.commit();
rsmckinney commented 4 months ago

feature added with release 2024.1.20