0
我需要爲篩選條件執行預查詢並傳遞結果以進行實際提取。MyBatis @Result映射到自我對象,而不是屬性
Select * from Table_a where id in (select id from Table_b where X=?)
MyBatis的映射如下所示
@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(「Select * from Table_a where where id in(select_table from Table_b where X =#{xValue,mode = IN,jdbcType = VARCHAR})」) ClassA getA(Integer id);' – griFlo
只是爲了讓更多碎片化方法並將單獨的表保持在一起 更改與tableB有關時dosenot需要在tableA的查詢中進行更改 – Rajadurai