简体   繁体   中英

How to fetch a list in struts 1.x using ibatis

Can any one tell me which function should I use to fetch a list/ character array using ibatis query . example are preferable .

XML

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE sqlMap
 PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
 "http://ibatis.apache.org/dtd/sql-map-2.dtd">
 <sqlMap namespace="sql">


    <resultMap id="playerMap" class="com.example.model.Player">
      <result property="name" column="name" />
      <result property="id" column="player_id" />
      <result property="email" column="email" />
      <result property="password" column="password" />
      <result property="avatarUrl" column="avatar_url" />
    </resultMap>

     <select id="getPlayers" resultMap="sql.playerMap">
       select * from player
    </select>
  </sqlMap>

DAO

public List<Player> getPlayers() {
   return (List<Player>)sqlMapClientTemplate.queryForList("sql.getPlayers");
}

Reference source: https://github.com/inktomi/SpringMVC/blob/master/src/main/java/com/example/dao/Dao.java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM