一对多、多对多(注解)

匿名 (未验证) 提交于 2019-12-02 23:40:02
 1.一对多用户和账户     @Select("select * from user")     @Results(id = "resultMap",value = {             @Result(id = true,property = "userId",column ="id"),             @Result(property = "userName",column ="username"),             @Result(property = "userSex",column ="sex"),             @Result(property = "userAddress",column ="address"),             @Result(property = "accounts",column ="id",many=@Many(select = "com.itheima.dao.IAccountDao.getAccountById",                     fetchType = FetchType.LAZY)),     })     List<User> findAll();      2.多对多   是由多个一对多组成,但是会产生中间表,上面的步骤相同,查询需要用到内连接   	@Select("SELECT * FROM role WHERE id IN(SELECT rid FROM user_role WHERE uid=#{id}) ")     Role getRoleById(Integer id);

文章来源: https://blog.csdn.net/qq1424035130/article/details/91446327
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!