Using multi-row insert, you can issue the following SQL:
insert into DEPARTMENT (DEPARTMENT_ID, DEPARTMENT_NO, DEPARTMENT_NAME, LOCATION, VERSION)
values (99, 99, 'aaa', 'bbb', 1), (100, 100, 'ccc', 'ddd', 1)
The Dao definition can be written as follows:
@Dao
public interface DepartmentDao {
@MultiInsert
int insertMutableEntities(List<Department> entities);
@MultiInsert
MultiResult<ImmutableDepartment> insertImmutableEntities(List<ImmutableDepartment> entities);
}
In the Criteria API, you can execute a multi-row insert by calling the insertMulti method as follows:
Department_ d = new Department_();
List<Department> departments = Arrays.asList(department, department2);
MultiResult<Department> result = entityql.insertMulti(d, departments).execute();
The databases that support this feature are as follows:
H2
MySQL 5
MySQL 8
PostgreSQL
SQL Server
However, in the case of SQL Server, this feature cannot be executed on tables with an auto-increment primary key.
This pull request supports multi-row insert.
Using multi-row insert, you can issue the following SQL:
The Dao definition can be written as follows:
In the Criteria API, you can execute a multi-row insert by calling the
insertMulti
method as follows:The databases that support this feature are as follows:
However, in the case of SQL Server, this feature cannot be executed on tables with an auto-increment primary key.