Package org.apache.ibatis.annotations
Annotation Interface SelectProvider
@Documented
@Retention(RUNTIME)
@Target(METHOD)
@Repeatable(List.class)
public @interface SelectProvider
The annotation that specify a method that provide an SQL for retrieving record(s).
How to use:
public interface UserMapper { @SelectProvider(type = SqlProvider.class, method = "selectById") User selectById(int id); public static class SqlProvider { public static String selectById() { return "SELECT id, name FROM users WHERE id = #{id}"; } } }
- Author:
- Clinton Begin
-
Nested Class Summary
-
Optional Element Summary
-
Element Details
-
value
Class<?> valueSpecify a type that implements an SQL provider method.- Returns:
- a type that implements an SQL provider method
- Since:
- 3.5.2
- See Also:
- Default:
- void.class
-
type
Class<?> typeSpecify a type that implements an SQL provider method.This attribute is alias of
value()
.- Returns:
- a type that implements an SQL provider method
- See Also:
- Default:
- void.class
-
method
String methodSpecify a method for providing an SQL.Since 3.5.1, this attribute can omit.
If this attribute omit, the MyBatis will call a method that decide by following rules.
-
If class that specified the
type()
attribute implements theProviderMethodResolver
, the MyBatis use a method that returned by it. -
If cannot resolve a method by
ProviderMethodResolver
(= not implement it or it was returnednull
, the MyBatis will search and use a fallback method that namedprovideSql
from specified type.
- Returns:
- a method name of method for providing an SQL
- Default:
- ""
-
If class that specified the
-
databaseId
String databaseId- Returns:
- A database id that correspond this provider
- Since:
- 3.5.5
- Default:
- ""
-
affectData
boolean affectDataReturns whether this select affects DB data.
e.g. RETURNING of PostgreSQL or OUTPUT of MS SQL Server.- Returns:
true
if this select affects DB data;false
if otherwise- Since:
- 3.5.12
- Default:
- false
-