LoginSignup
1
0

More than 5 years have passed since last update.

MyBatisでマッパーxmlの記載方法

Posted at

以下のようなTestMapper.xml、TestMapper.javaが存在します。

TestMapper.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="common.mappers.TestMapper">
    <resultMap id="ResultTest" type="common.entities.Test">
        <id column="id" jdbcType="INTEGER" property="id" />
        <result column="name" jdbcType="VARCHAR" property="name" />
        <result column="flg" jdbcType="INTEGER" property="flg" />
    </resultMap>

    <select id="selectByTest" parameterType="Test" resultMap="ResultTest">
        select *
        from test
    </select>
</mapper>
TestMapper.java
package common.mappers;
import ccommon.entities.Test;
public interface TestMapper {
    List<Test> selectByTest();
}

その後、javaクラス(Interceptorクラス)で使用する際にListで使用したい場合は上記のような記述で問題ないでしょうか?
また、全件検索なのですが、上のような書き方のListで問題ないでしょうか?

ご教示いただける方がいましたらお願いいたします。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0