1. update
Update records matching the given condition. Supports both Condition and List.
// Single Condition
public int update(String table, Map bean, Condition condition)
public int update(Table table, Map bean, Condition condition)
// List<Condition>
public int update(String table, Map bean, List<Condition> conditions)
public int update(Table table, Map bean, List<Condition> conditions)
Returns: int — number of affected rows.
Example:
// Using Condition
jt.update("user_table", values, F("id").eq(user.getId()));
// Using List<Condition>
jt.update("user_table", values,
jt.conditions("id", user.getId(), "name<>", user.getName()));
// Using Table object
jt.update(T("user_table"), values, jt.conditions("id", user.getId()));
2. updatev (varargs conditions)
Specify update conditions via varargs without manually constructing Condition objects. Operators can be embedded in field names.
public int updatev(String table, Map bean, Object... where)
public int updatev(Table table, Map bean, Object... where)
Returns: int — number of affected rows.
Example:
// Equality WHERE id = ?
jt.updatev("user_table", values, "id", user.getId());
// Multiple conditions WHERE id = ? AND name <> ?
jt.updatev("user_table", values,
"id", user.getId(), "name<>", user.getName());
// Mix Condition
jt.updatev(T("user_table"), values,
"id", user.getId(), "name:isnotnull");
Top comments (0)