Skip to main content
Hint

This article is generated by AI translation.

@Execute Annotation

Marks an interface method to execute any SQL statement (DML/DDL).

info

If you pass a string array, the elements are concatenated with a single space between them.
String arrays make it easy to manage multi-line SQL.

Example: create a sharded users table
@SimpleMapper
public interface UserMapper {
@Execute({"create table users_${part} (",// 1. SQL definition
" id int primary key,", //
" name varchar(50)", //
")"})
int newPartTable(
@Param("part") int partId // 2. partId argument
);
}
  • ${part} uses direct string substitution to pass the argument (beware of SQL injection risks).

Properties

PropertyDescription
value必选 SQL to execute.
statementType可选 Determines which JDBC statement type to use. Default is PREPARED.
- STATEMENTjava.sql.Statement
- PREPAREDjava.sql.PreparedStatement
- CALLABLEjava.sql.CallableStatement
timeout可选 If set to a value greater than 0, the value is applied to java.sql.Statement.setQueryTimeout(int) to enforce a timeout in seconds. Default is -1.
bindOut可选 Bind output parameter names, used to receive stored procedure output arguments or multiple result sets.
When using this attribute, the method return type must be Map<String,Object>.