Java 如何使用mybatis注释实现关系查询

Java 如何使用mybatis注释实现关系查询,java,spring-boot,mybatis,spring-mybatis,Java,Spring Boot,Mybatis,Spring Mybatis,我有A,B,C三个表,B有A的id,C有B的id。A:B=1:N,B:C=1:N,现在我在C中查询一些数据,也对应于AB表中的数据。我应该如何处理mybatis注释?如果只需要处理关系查询,那么使用xml映射器文件会更容易 在那里,你可以写这样的东西来得到一个特定的a项目和他的B <resultMap id="aResultMap" type="hello.A"> <id property="ida" column="id_a"/> <collect

我有A,B,C三个表,B有A的id,C有B的id。A:B=1:N,B:C=1:N,现在我在C中查询一些数据,也对应于AB表中的数据。我应该如何处理mybatis注释?

如果只需要处理关系查询,那么使用xml映射器文件会更容易

在那里,你可以写这样的东西来得到一个特定的a项目和他的B

<resultMap id="aResultMap" type="hello.A">
    <id property="ida" column="id_a"/>
    <collection property="bs" javaType="ArrayList" column="ida" ofType="hello.B" select="selectBs"/>
</resultMap>

<select id="selectOneA" resultMap="aResultMap">
    SELECT * FROM A
    WHERE ida = #{idA}
</select>

<select id="selectBs" resultType="HashMap">
    SELECT * FROM B
    WHERE ida = #{idA}
</select>

从列表中选择*
其中ida={ida}
从B中选择*
其中ida={ida}
你可以查一下myBatis医生

如果只需要处理关系查询,那么使用xml映射器文件会更容易

在那里,你可以写这样的东西来得到一个特定的a项目和他的B

<resultMap id="aResultMap" type="hello.A">
    <id property="ida" column="id_a"/>
    <collection property="bs" javaType="ArrayList" column="ida" ofType="hello.B" select="selectBs"/>
</resultMap>

<select id="selectOneA" resultMap="aResultMap">
    SELECT * FROM A
    WHERE ida = #{idA}
</select>

<select id="selectBs" resultType="HashMap">
    SELECT * FROM B
    WHERE ida = #{idA}
</select>

从列表中选择*
其中ida={ida}
从B中选择*
其中ida={ida}
你可以查一下myBatis医生

您能再详细说明一下吗?您能再详细说明一下吗?