Skip to main content
Hint

This article is generated by AI translation.

Receive Data with List/Map

Using Map to receive query results is the most versatile approach. Each row is represented as a Map<String, Object> mapping column names to values, without needing to predefine entity classes.

Single row query
Map<String, Object> data = jdbc.queryForMap("select * from users where id = 1");

How to Use

Example: Programmatic API
List<Map<String, Object>> result = jdbc.queryForList("select * from users");
Example: Declarative API
@SimpleMapper
public interface UserMapper {
@Query("select * from users where id > #{id}")
List<Map<String, Object>> listUsers(@Param("id") long searchId);
}
Example: Fluent API
List<Map<String, Object>> result = lambda.query(User.class)
.le(User::getId, 100)
.queryForMapList();
Example: Mapper File
<select id="queryListByAge" resultType="map">
select * from users where age = #{age}
</select>
resultType options
ValueCorresponding TypeDescription
mapLinkedCaseInsensitiveMap (default)Column name case-insensitive, affected by global configuration
hashmapHashMapUnordered, column name case-sensitive
linkedmapLinkedHashMapMaintains insertion order, column name case-sensitive
caseinsensitivemapLinkedCaseInsensitiveMapColumn name case-insensitive