Parameters MyBatis@Result映射到自对象而不是属性

Parameters MyBatis@Result映射到自对象而不是属性,parameters,mybatis,ibatis,Parameters,Mybatis,Ibatis,我需要对过滤条件执行一个预查询,并将结果传递给实际获取 Select * from Table_a where id in ( select id from Table_b where X=?) MyBatis Mapper如下所示 @Select("Select * from Table_a where id in (#{id, mode=IN, jdbcType=INTEGER})") ClassA getA(Integer id); @Select("select id from Ta

我需要对过滤条件执行一个预查询,并将结果传递给实际获取

Select * from Table_a where id in ( select id from Table_b where X=?)
MyBatis Mapper如下所示

@Select("Select * from Table_a where id in (#{id, mode=IN, jdbcType=INTEGER})")
ClassA getA(Integer id);

@Select("select id from Table_b where X=#{xValue, mode=IN, jdbcType=VARCHAR}")
@Results(value = { @Result( property = "this", column = "ID", one = @One(select = "getA")) })
ClassA getAfromB(String xValue);
如何将结果映射到整个对象而不是命名参数

我知道我可以获得ClassB的实例,并使用getter访问ClassA。 有直达的方法吗?或
myBatis提供了这样一种添加筛选结果的方法?

实际上,一个查询就足够了,最好避免使用联接进行子选择:

SELECT * FROM Table_A a JOIN Table_B b ON a.id = b.id AND b.X=#{xValue, mode=IN, jdbcType=VARCHAR}

你为什么不在一个选择中这样做@从表格a中选择select*,其中id在表格b中选择id,其中X={xValue,mode=in,jdbcType=VARCHAR}ClassA getAInteger id;只是为了在更改与tableB相关时采用更分散的方法并一起维护单独的表,不需要在使用tableA的查询中进行更改