org.apache.ibatis.annotations.MapKey Java Examples

The following examples show how to use org.apache.ibatis.annotations.MapKey. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapperMethod.java    From mybaties with Apache License 2.0 5 votes vote down vote up
private String getMapKey(Method method) {
  String mapKey = null;
  if (Map.class.isAssignableFrom(method.getReturnType())) {
    //如果返回类型是map类型的,查看该method是否有MapKey注解。如果有这个注解,将这个注解的值作为map的key
    final MapKey mapKeyAnnotation = method.getAnnotation(MapKey.class);
    if (mapKeyAnnotation != null) {
      mapKey = mapKeyAnnotation.value();
    }
  }
  return mapKey;
}
 
Example #2
Source File: MapperMethod.java    From mybatis with Apache License 2.0 5 votes vote down vote up
private String getMapKey(Method method) {
  String mapKey = null;
  if (Map.class.isAssignableFrom(method.getReturnType())) {
    //如果返回类型是map类型的,查看该method是否有MapKey注解。如果有这个注解,将这个注解的值作为map的key
    final MapKey mapKeyAnnotation = method.getAnnotation(MapKey.class);
    if (mapKeyAnnotation != null) {
      mapKey = mapKeyAnnotation.value();
    }
  }
  return mapKey;
}
 
Example #3
Source File: Mapper.java    From mybaties with Apache License 2.0 4 votes vote down vote up
@Select("select id, name from users")
@MapKey("id")
Map<Integer, User<String>> getAMapOfUsers();
 
Example #4
Source File: PersonMapper.java    From mybaties with Apache License 2.0 4 votes vote down vote up
@Select("select * from person")
@MapKey("id")
Map<Integer, Person> selectAsMap();
 
Example #5
Source File: Mapper.java    From mybatis with Apache License 2.0 4 votes vote down vote up
@Select("select id, name from users")
@MapKey("id")
Map<Integer, User<String>> getAMapOfUsers();
 
Example #6
Source File: PersonMapper.java    From mybatis with Apache License 2.0 4 votes vote down vote up
@Select("select * from person")
@MapKey("id")
Map<Integer, Person> selectAsMap();