1)类

 public class AppData
{
// public int ModuleId { get; set; }
public int DataId { get; set; }
public int DataSequence { get; set; }
public string ContentValue { get; set; }
}
public class AppModuleJoin
{
//public int PageId { get; set; }
public int ModuleId { get; set; }
public IList<AppData> DataList { get; set; }
//public int DataId { get; set; }
//public int DataSequence { get; set; }
//public string ContentValue { get; set; }
}
public class AppModule
{
//public int PageId { get; set; }
public int ModuleId { get; set; } //public int DataId { get; set; }
//public int DataSequence { get; set; }
//public string ContentValue { get; set; }
}
public class AppPageJoin
{
public int PageId { get; set; }
public IList<AppModuleJoin> ModuleList { get; set; }
}
public class AppPage
{
public int PageId { get; set; } }

  sqlxml

<?xml version="1.0" encoding="utf-8" ?>
<!--<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">-->
<sqlMap namespace="App" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
<typeAlias alias="AppPageJoin" type="IBatis.AppPageJoin"/>
<typeAlias alias="AppPage" type="IBatis.AppPage"/>
<typeAlias alias="AppModule" type="IBatis.AppModule"/>
<typeAlias alias="AppModuleJoin" type="IBatis.AppModuleJoin"/>
<typeAlias alias="AppData" type="IBatis.AppData"/>
</alias>
<resultMaps>
<!--<resultMap id="AppModuleReslut" class="AppModule">
--><!--<result property="PageId" column="PageId"/>--><!--
<result property="ModuleId" column="ModuleId"/>
<result property="DataId" column="DataId"/>
<result property="DataSequence" column="DataSequence"/>
<result property="ContentValue" column="ContentValue"/>
</resultMap>--> <resultMap id="AppDataReslut" class="AppData">
<!--<result property="PageId" column="PageId"/>-->
<!--<result property="ModuleId" column="ModuleId"/>-->
<result property="DataId" column="DataId"/>
<result property="DataSequence" column="DataSequence"/>
<result property="ContentValue" column="ContentValue"/>
</resultMap> <resultMap id="AppModuleReslut" class="AppModule">
<!--<result property="PageId" column="PageId"/>-->
<result property="ModuleId" column="ModuleId"/> </resultMap> <resultMap id="AppPageReslut" class="AppPage">
<result property="PageId" column="PageId"/>
</resultMap> <resultMap id="AppPageModuleJoinReslut" class="AppModuleJoin" extends="AppModuleReslut" groupBy="ModuleId">
<result property="DataList" resultMapping="App.AppDataReslut" />
</resultMap> <resultMap id="AppPageJoinReslut" class="AppPageJoin" extends="AppPageReslut" groupBy="PageId">
<result property="ModuleList" resultMapping="App.AppPageModuleJoinReslut" />
</resultMap>
</resultMaps>
<statements>
<select id="QueryData" resultMap="AppPageJoinReslut">
select *
from QueryData
</select> </statements>
</sqlMap>

在调用中

 public IList<AppPageJoin> QueryData()
{
ISqlMapper mapper = _sqlMap;
IList<AppPageJoin> ListPerson = mapper.QueryForList<AppPageJoin>("QueryData", null); //这个"SelectAllPerson"就是xml映射文件的Id
return ListPerson;
}

IBatis一对多嵌套查询的更多相关文章

  1. mybatis一对一 和 一对多 嵌套查询

    实际项目中的,接口对外VO  会出现 一对一 和 一对多的情况,举例:小区 下面有 楼栋  ,楼栋 下面有 房屋    ,   房屋里面又房间 小区Vo  : districtVo { id: nam ...

  2. 使用mybatis进行一对多嵌套查询时出错:输出结果:Country{id=2, name='美国', minister=[null]}

    即Minister类作为Country类的关联属性. 查询的输出结果是:Country{id=2, name='美国', minister=[null]} <!--mapper.xml内容--& ...

  3. 嵌套查询--------关联一对多关系----------collection

    参考来源:   http://www.cnblogs.com/LvLoveYuForever/p/6689577.html <resultMap id="BaseResultMap&q ...

  4. ibatis 中动态SQL查询和动态标签嵌套的使用

    ibatis 动态查询对于从事 Java EE 的开发人员来说,iBatis 是一个再熟悉不过的持久层框架了,在 Hibernate.JPA 这样的一站式对象 / 关系映射(O/R Mapping)解 ...

  5. 7.mybatis一对多关联查询

    和第5节一对一查询类似,但是不同的是,一对一使用的是association,而一对多使用collection. 实例: 1个班级Class,对应1个老师Teacher,对应多个学生Student 1. ...

  6. elasticsearch elk最全java api 搜索 聚合、嵌套查询

    目录 一. 一般查询... 2 (一) matchAllQuery(client). 2 (二) matchQuery(client);3 (三) multiMatchQuery(client);3 ...

  7. mybatis的动态sql编写以及一对一关系查询和一对多的查询

    创建mybatis数据库,运行以下sql语句 /* SQLyog Ultimate v8.32 MySQL - 5.5.27 : Database - mybatis **************** ...

  8. mybatis中使用懒加载实现一对多复杂查询

    1.包结构 2.pom配置 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=&qu ...

  9. Mybatis通过接口实现一对一及一对多的查询

    实现一对一是采用association方法: <resultMap type="testId" id="users"> <associatio ...

随机推荐

  1. SD卡状态广播

    SD状态发生改变的时候会对外发送广播.SD卡的状态一般有挂载.未挂载和无SD卡. 清单文件 一个广播接受者可以接受多条广播.这里在意图过滤器中添加是data属性是因为广播也需要进行匹配的.对方发送的广 ...

  2. Webservice学习

    参考博客1: http://www.cnblogs.com/lzhp/archive/2013/01/13/2858559.html 参考博客2:http://blog.csdn.net/shilei ...

  3. XML的解析和保存

    1.XML(extensible markup language;XML )  定义:,可以用来标记数据.定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言.     XML语法规范:  标 ...

  4. 34-nl 简明笔记

    为文本文件添加行号 nl [options] files 参数 files是nl需要为其添加行号的文本文件路径名,如果有多个文件,则nl会把多个文件合在一起编号,并输出到标准输出上 选项 -b     ...

  5. 在Word2013中多次应用格式刷

    顾名思义,格式刷是为了方便需要跨区域操作时候,能快速的应用格式到相应文本.那么怎么使用word进行格式刷的多次使用呢.我们先来看单次的,这个比较容易,只要在先需要的格式单击一次格式刷,再到需要的文本执 ...

  6. Android Material Design 控件常用的属性

    android:fitsSystemWindows="true" 是一个boolean值的内部属性,让view可以根据系统窗口(如status bar)来调整自己的布局,如果值为t ...

  7. windows-msconfig

    弹出输入框,输入命令msconfig 打开系统配置,查看相关引导信息,关闭开机启动等

  8. 详解Mac配置虚拟环境Virtualenv

    virtualenv 可以用来建立一个专属于项目的python环境,保持一个干净的环境.只需要通过命令创建一个虚拟环境,不用的时候通过命令退出,删除. 下面介绍一下安装方法: 安装 virtualen ...

  9. python 模块的介绍(一)

    模块让你能够有逻辑地组织你的Python代码段. 把相关的代码分配到一个 模块里能让你的代码更好用,更易懂. 模块也是Python对象,具有随机的名字属性用来绑定或引用. 简单地说,模块就是一个保存了 ...

  10. 【poj1386】 Play on Words

    http://poj.org/problem?id=1386 (题目链接) 题意 给出n个单词,判断它们能否首尾相接的排列在一起. Solution 将每一格单词的首字母向它的尾字母连一条有向边,那么 ...