首页 新闻 会员 周边

mybatis中 @Result 注解 调用其他查询,参数传递

0
悬赏园豆:100 [已解决问题] 解决于 2019-08-08 13:25

@Select("<script> select * from user where userId=#{user.userId} <if test="user.userName != null"> and userName = #{user.userName}</if> </script>")
@Results({
@Result(property = "userId",column = "userId"),
@Result(property = "userName",column = "userName"),
@Result(property = "msg",column = "msg"),
@Result(property = "telephones", javaType = List.class, column = "{userId=userId, shardName=shardName}", many = @Many(select = "com.limz.mysql.dsmysql.Dao.TelephoneDao.findTelephoneByUserId"))})
List<User> query(@Param("user") User user, @Param("shardName") String shardName);

@Select("select * from telephone where userId = #{userId}")
List<Telephone> findTelephoneByUserId(String shardName, String userId);

请问此处, 如何将主查询中的参数 shardName 传递到调用的@Many查询中

我是小明呀嘿的主页 我是小明呀嘿 | 初学一级 | 园豆:104
提问于:2018-11-15 13:38
< >
分享
最佳答案
0

在主查询中,添加一列结果 #{shardName} as shardName ,在调用的查询中获取此参数

我是小明呀嘿 | 初学一级 |园豆:104 | 2018-11-15 14:05
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册