domaframework / doma

DAO oriented database mapping framework for Java
https://doma.readthedocs.io/
Apache License 2.0
440 stars 70 forks source link

Feature Request: Bulk Insert #1129

Closed orekyuu closed 2 months ago

orekyuu commented 3 months ago

Description Currently, Doma2 does not support Bulk Insert. Currently, to achieve Bulk Insert, it is necessary to write an SQL Template like the following:

insert into users(name, age)
values /*%for e : entities*/
  (/*e.name*/'user', /*e.age*/20)
  /*%if e_has_next */ /*# "," */ /*%end */
/*%end */

Implementation ideas We would like to be able to write it as follows:

interface UserDao {
  @BulkInsert
  int bulkInsert(List<UserEntity> users);

  @BulkInsert
  BulkResult<ImmutableUserEntity> bulkInsert(List<ImmutableUserEntity> users);
}

If there are no problem, I would like to try writing a Pull Request to add this feature.

nakamura-to commented 3 months ago

Thank you for your feedback. Your pull requests are welcome.