数据库表

角色组表:

CREATE TABLE `sso_character_group` (
`group_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '角色组ID',
`group_name` varchar(255) DEFAULT NULL COMMENT '角色组名称',
PRIMARY KEY (`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

角色表:

CREATE TABLE `sso_character` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '角色ID',
`name` varchar(255) DEFAULT NULL COMMENT '角色名称',
`group_id` int(11) DEFAULT NULL COMMENT '所属角色组ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

一个角色组包含多个角色

两个POJO

//CharacterGroup.java
package cn.com.hiveview.entity.module.portal;
import lombok.Data; @Data
public class CharacterCondition {
private Integer id;
private String name;
} //Character.java
package cn.com.hiveview.entity.module.portal; import lombok.Data;
import java.util.List; @Data
public class CharacterGroupCondition {
private Integer groupId;
private String groupName;
private List<CharacterCondition> characterList;
}

controller--mapper层都是直接调用下一层,此处省略

直接上mapper.xml

     <resultMap id="characterGroup" type="cn.com.hiveview.entity.module.portal.CharacterGroupCondition">
<id column="group_id" property="groupId"/>
<result column="group_name" property="groupName"/>
<collection property="characterList" column="{groupId=group_id}" select="getCharacterList"/>
</resultMap> <select id="getList" resultMap="characterGroup" parameterType="cn.com.hiveview.entity.module.portal.CharacterGroupCondition">
SELECT group_id,group_name FROM sso_character_group
</select> <select id="getCharacterList" resultType="cn.com.hiveview.entity.module.portal.CharacterCondition">
select id,name from sso_character where group_id=#{groupId}
</select>

结果展示

最新文章

  1. Android入门(十):界面的布局方式及其实际应用
  2. Android Studio 自定义debug签名文件keystore
  3. nodejs events模块
  4. android 入门-android属性介绍
  5. VmWare Workstation 10 安装 Ubuntu 14.04 问题解决
  6. CodeForces 527B Error Correct System
  7. 利用MiddleGen-hibernate-r5生成hbm文件及POJO文件
  8. Cocos2d-x 3.0final 终结者系列教程01-无论是从cocos2d-x2.x升级到版本cocos2d-x3.x
  9. java并发之固定对象与实例
  10. PHP获取字符串编码与转码
  11. Why Are Thread.stop, Thread.suspend, Thread.resume and Runtime.runFinalizersOnExit Deprecated ?
  12. BZOJ 3674 可持久化并查集
  13. 免费ss账号网站
  14. PowerDesign生成数据库
  15. 【Java】【路径】
  16. CS程序中XML编码Encode和解码Decode
  17. asp.net mvc5 安装
  18. 【第三章】Shell 变量的数值计算
  19. (beta冲刺5/7)
  20. java栈的实现

热门文章

  1. C#调用smtp邮件发送几个大坑
  2. PDF.JS 读取文件流前端展示 C#
  3. Delphi中的Val函数和iif函数(出错的时候,会有索引值)
  4. 修改Samba密码后无法登录
  5. 0016 CSS 背景:background
  6. windows下PostgreSQL 安装与配置
  7. iptables 添加80端口规则
  8. java基础之----分布式事务tcc
  9. 通俗易懂理清mybatis中SqlSessionSql、SqlSessionTemplate、SessionFactory和SqlSessionFactoryBean之间的关系
  10. 6.python在windows下用批处理文件在运行中输入程序名直接运行的方法