@Documented @Retention(value=RUNTIME) @Target(value=METHOD) @Repeatable(value=UpdateProvider.List.class) public @interface UpdateProvider
How to use:
public interface UserMapper {
@UpdateProvider(type = SqlProvider.class, method = "update")
boolean update(User user);
public static class SqlProvider {
public static String update() {
return "UPDATE users SET name = #{name} WHERE id = #{id}";
}
}
}
| Modifier and Type | Optional Element and Description |
|---|---|
String |
databaseId |
String |
method
Specify a method for providing an SQL.
|
Class<?> |
type
Specify a type that implements an SQL provider method.
|
Class<?> |
value
Specify a type that implements an SQL provider method.
|
public abstract String method
Since 3.5.1, this attribute can omit. If this attribute omit, the MyBatis will call a method that decide by following rules.
type() attribute implements the
ProviderMethodResolver,
the MyBatis use a method that returned by it
ProviderMethodResolver(= not implement it or it was returned null),
the MyBatis will search and use a fallback method that named provideSql from specified type
public abstract String databaseId
Copyright © 2009–2021 MyBatis.org. All rights reserved.