@Execute
Marks an interface method to execute any SQL statement (both DML and DDL).
info
value supports string arrays. Elements are joined with spaces, convenient for multi-line writing.
Example: create a sharded table
@SimpleMapper
public interface UserMapper {
@Execute({"create table users_${part} (",
" id int primary key,",
" name varchar(50)",
")"})
int newPartTable(@Param("part") int partId);
}
${part} uses string substitution (be aware of SQL injection risks).
Properties
| Property | Description |
|---|---|
| value | Required The SQL statement to be executed. |
| statementType | Optional JDBC execution mode. Default Prepared- Statement → java.sql.Statement- Prepared → java.sql.PreparedStatement- Callable → java.sql.CallableStatement |
| timeout | Optional Execution timeout in seconds. Default -1 |
| bindOut | Optional Bind output parameters, for use with stored procedures or multiple result sets. When set, the return type must be Map<String,Object> |