Annotation Type InsertProvider


  • @Documented
    @Retention(RUNTIME)
    @Target(METHOD)
    @Repeatable(List.class)
    public @interface InsertProvider
    The annotation that specify a method that provide an SQL for inserting record(s).

    How to use:

     public interface UserMapper {
    
       @InsertProvider(type = SqlProvider.class, method = "insert")
       void insert(User user);
    
       public static class SqlProvider {
         public static String insert() {
           return "INSERT INTO users (id, name) VALUES(#{id}, #{name})";
         }
       }
    
     }
     
    Author:
    Clinton Begin
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String databaseId  
      String method
      Specify a method for providing an SQL.
      Class<?> type
      Specify a type that implements an SQL provider method.
      Class<?> value
      Specify a type that implements an SQL provider method.
    • Element Detail

      • value

        Class<?> value
        Specify a type that implements an SQL provider method.
        Returns:
        a type that implements an SQL provider method
        Since:
        3.5.2
        See Also:
        type()
        Default:
        void.class
      • type

        Class<?> type
        Specify a type that implements an SQL provider method.

        This attribute is alias of value().

        Returns:
        a type that implements an SQL provider method
        See Also:
        value()
        Default:
        void.class
      • method

        String method
        Specify a method for providing an SQL.

        Since 3.5.1, this attribute can omit. If this attribute omit, the MyBatis will call a method that decide by following rules.

        • If class that specified the type() attribute implements the ProviderMethodResolver, the MyBatis use a method that returned by it
        • If cannot resolve a method by ProviderMethodResolver(= not implement it or it was returned null), the MyBatis will search and use a fallback method that named provideSql from specified type
        Returns:
        a method name of method for providing an SQL
        Default:
        ""
      • databaseId

        String databaseId
        Returns:
        A database id that correspond this provider
        Since:
        3.5.5
        Default:
        ""