Annotation Interface Insert


@Target(METHOD) @Retention(RUNTIME) public @interface Insert
Indicates an insert operation.

The annotated method must be a member of a Dao annotated interface.

 @Entity
 public class Employee {
     ...
 }

 @Dao
 public interface EmployeeDao {

     @Insert
     int insert(Employee employee);
 }
 
The method may throw following exceptions:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    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.
    The properties whose mapped columns are excluded from SQL INSERT statements.
    boolean
    Whether SQL NULL columns are excluded from SQL INSERT statements.
    The properties whose mapped columns are included in SQL INSERT statements.
    int
    The 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 queryTimeout
      The query timeout in seconds.

      If not specified, Config.getQueryTimeout() is used.

      Returns:
      the query timeout
      See Also:
      Default:
      -1
    • excludeNull

      boolean excludeNull
      Whether SQL NULL columns are excluded from SQL INSERT statements.

      Only if sqlFile() is false, this element value is used.

      Returns:
      whether SQL NULL columns are excluded
      Default:
      false
    • include

      String[] include
      The properties whose mapped columns are included in SQL INSERT statements.

      Only if sqlFile() is false, this element value is used.

      Returns:
      the included properties
      Default:
      {}
    • exclude

      String[] exclude
      The properties whose mapped columns are excluded from SQL INSERT statements.

      Only if sqlFile() is false, this element value is used.

      Returns:
      the excluded properties
      Default:
      {}
    • sqlLog

      SqlLogType sqlLog
      Returns:
      the output format to be used for SQL logs when this insert operation is executed.
      Default:
      FORMATTED
    • duplicateKeyType

      DuplicateKeyType duplicateKeyType
      This 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[] duplicateKeys
      This variable represents the keys that should be used to determine if a duplicate key exists. If the duplicate key exists, the operation will use the duplicateKeyType() strategy to handle the duplicate key.

      Note: This value is only utilized when the duplicateKeyType() value is either DuplicateKeyType.UPDATE or DuplicateKeyType.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:
      {}
    • returning

      Returning returning
      Returns:
      the Returning annotation configuration, which defines inclusions or exclusions for returning values.
      Default:
      @org.seasar.doma.Returning