Indicates a batch insert operation.
The annotated method must be a member of a Dao annotated interface.
@Entity
public class Employee {
...
}
@Dao
public interface EmployeeDao {
@BatchInsert
int[] insert(List<Employee> employee);
}
The method may throw following exceptions:
DomaNullPointerExceptionif any of the method parameters arenullUniqueConstraintExceptionif an unique constraint is violatedSqlFileNotFoundExceptionifsqlFileistrueand the SQL file is not foundJdbcExceptionif a JDBC related error occurs
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionintThe batch size.String[]This variable represents the keys that should be used to determine if a duplicate key exists.This variable represents the type of duplicate key handling strategy for an insert operation.String[]The properties whose mapped columns are excluded from SQL INSERT statements.booleanWhether auto-generated keys are not retrieved from the database to improve performance.String[]The properties whose mapped columns are included in SQL INSERT statements.intThe query timeout in seconds.boolean
-
Element Details
-
sqlFile
boolean sqlFile- Returns:
- whether the annotated method should be mapped to an SQL file.
- Default:
- false
-
queryTimeout
int queryTimeoutThe query timeout in seconds.If not specified,
Config.getQueryTimeout()is used.- Returns:
- the query timeout
- See Also:
- Default:
- -1
-
batchSize
int batchSizeThe batch size.If not specified,
Config.getBatchSize()is used.This value is used when
Statement.executeBatch()is executed.- Returns:
- the batch size
- See Also:
- Default:
- -1
-
include
String[] includeThe properties whose mapped columns are included in SQL INSERT statements.Only if
sqlFile()isfalse, this value is available.- Returns:
- the included properties
- Default:
- {}
-
exclude
String[] excludeThe properties whose mapped columns are excluded from SQL INSERT statements.Only if
sqlFile()isfalse, this value is available.- Returns:
- the excluded properties
- Default:
- {}
-
sqlLog
SqlLogType sqlLog- Returns:
- the output format of SQL logs.
- Default:
- FORMATTED
-
ignoreGeneratedKeys
boolean ignoreGeneratedKeysWhether auto-generated keys are not retrieved from the database to improve performance. If this flag is enabled, entities won't have auto-generated keys.- Returns:
- Whether auto-generated keys are not retrieved.
- Default:
- false
-
duplicateKeyType
DuplicateKeyType duplicateKeyTypeThis variable represents the type of duplicate key handling strategy for an insert operation. It can have one of three values:- UPDATE: If a duplicate key is encountered, the existing row in the table will be updated.
- IGNORE: If a duplicate key is encountered, the insert operation will be ignored, and no changes will be made to the table.
- EXCEPTION: If a duplicate key is encountered, the operation will throw an exception, indicating that a duplicate key exists.
- Returns:
- the type of duplicate key handling strategy for an insert operation.
- Default:
- EXCEPTION
-
duplicateKeys
String[] duplicateKeysThis variable represents the keys that should be used to determine if a duplicate key exists. If the duplicate key exists, the operation will use theduplicateKeyType()strategy to handle the duplicate key.Note: This value is only utilized when the
duplicateKeyType()value is eitherDuplicateKeyType.UPDATEorDuplicateKeyType.IGNORE.Note: Certain DBMSs, such as MySQL, do not utilize this value.
- Returns:
- the keys that should be used to determine if a duplicate key exists.
- Default:
- {}
-