Skip to main content

@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

PropertyDescription
valueRequired The SQL statement to be executed.
statementTypeOptional JDBC execution mode. Default Prepared
- Statementjava.sql.Statement
- Preparedjava.sql.PreparedStatement
- Callablejava.sql.CallableStatement
timeoutOptional Execution timeout in seconds. Default -1
bindOutOptional Bind output parameters, for use with stored procedures or multiple result sets. When set, the return type must be Map<String,Object>