Package org.apache.ibatis.annotations
Annotation Interface TypeDiscriminator
The annotation that be grouping conditional mapping definitions.
How to use:
public interface UserMapper {
@Select("SELECT id, name, type FROM users ORDER BY id")
@TypeDiscriminator(
column = "type",
javaType = String.class,
cases = {
@Case(value = "1", type = PremiumUser.class),
@Case(value = "2", type = GeneralUser.class),
@Case(value = "3", type = TemporaryUser.class)
}
)
List<User> selectAll();
}
- Author:
- Clinton Begin
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?> Return the java type for conditional value.Return the jdbc type for column that hold conditional value.Class<? extends TypeHandler> Returns theTypeHandlertype for retrieving a column value from result set.
-
Element Details
-
column
String columnReturns the column name(column label) that hold conditional value.- Returns:
- the column name(column label)
-
javaType
Class<?> javaTypeReturn the java type for conditional value.- Returns:
- the java type
- Default:
void.class
-
jdbcType
JdbcType jdbcTypeReturn the jdbc type for column that hold conditional value.- Returns:
- the jdbc type
- Default:
UNDEFINED
-
typeHandler
Class<? extends TypeHandler> typeHandlerReturns theTypeHandlertype for retrieving a column value from result set.- Returns:
- the
TypeHandlertype
- Default:
org.apache.ibatis.type.UnknownTypeHandler.class
-
cases
Case[] casesReturns conditional mapping definitions.- Returns:
- conditional mapping definitions
-