Skip to main content
Hint

This article is generated by AI translation.

@Update Annotation

Marks an interface method and accepts a string or string array that represents an UPDATE 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: update a user name by id
@SimpleMapper
public interface UserMapper {
@Update({"update users", // 1. SQL definition
"set name = #{newName}", //
"where id = #{userId}"}) //
int updateUserName( // 2. userId & newName arguments
@Param("userId") int userId,
@Param("newName") int newName
);
}

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.