Hint
This article is generated by AI translation.
@Execute Annotation
Marks an interface method and accepts a string or string array that represents any SQL statement.
info
If you pass a string array, the elements are concatenated with a single space between them.
This makes it easy to manage SQL in a readable way.
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}is injected directly into the SQL string.
Properties
| Property | Description |
|---|---|
| value | 必选 SQL to execute. |
| statementType | 可选 Determines which JDBC statement type to use. Default is PREPARED.- STATEMENT → java.sql.Statement- PREPARED → java.sql.PreparedStatement- CALLABLE → java.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 | 可选 Filters output arguments to decide which ones will be received. If omitted, all arguments are captured. Once configured, the method return type must be Map<String,Object>. |