プロパティ名がSQLの結果と一致する場合
結果Beanのプロパティに一致する場合は resultMap ではなく、 resultClass で直接結果格納用のクラスを書けば処理される
<resultMap id="result" class="tutorial.User"> <result property="id" column="id" columnIndex="1"/> <result property="name" column="name" columnIndex="2"/> <result property="password" column="password" columnIndex="3"/> <result property="salary" column="salary" columnIndex="4"/> </resultMap> <select id="getAll" resultMap="result"> SELECT id,name,password,salary FROM suser ORDER by id </select>
は次のように書いても問題ない
<select id="getAll" resultClass="tutorial.User"> SELECT id,name,password,salary FROM suser ORDER by id </select>