mybatis关联查询一对多问题解决,将表中对应的多条数据以list形式存储
来源:互联网 发布:广州数据恢复 24小时 编辑:程序博客网 时间:2024/06/12 14:36
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="GmsMapLayerMapper"><insert id="save" useGeneratedKeys="true" keyProperty="id">insertinto gms_map_layer ( map_id, layer_id, name, has_index, datasource_id, display_order, geo_type, visible, create_time, update_time, data_layer_name, editable, category, sub_category) values ( #{mapId}, #{layerId}, #{name}, #{hasIndex}, #{datasourceId}, #{displayOrder}, #{geoType}, #{visible}, #{createTime}, #{updateTime}, #{dataLayerName}, #{editable}, #{category}, #{subCategory})</insert><select id="query" resultMap="resultMap">select * from gms_map_layer<where>1=1 <if test="id != null"> and id=#{id} </if> <if test="mapId != null"> and map_id=#{mapId} </if> <if test="layerId != null"> and layer_id=#{layerId} </if> <if test="name != null and name != ''"> and name=#{name} </if> <if test="hasIndex != null"> and has_index=#{hasIndex} </if> <if test="datasourceId != null"> and datasource_id=#{datasourceId} </if> <if test="displayOrder != null"> and display_order=#{displayOrder} </if> <if test="visible != null and visible != ''"> and visible=#{visible} </if> <if test="geoType != null"> and geo_type=#{geoType} </if> <if test="createTime != null"> and create_time=#{createTime} </if> <if test="updateTime != null"> and update_time=#{updateTime} </if> <if test="dataLayerName != null and dataLayerName != ''"> and data_layer_name=#{dataLayerName} </if> <if test="editable != null"> and editable=#{editable} </if> <if test="category != null and category != ''"> and category=#{category} </if> <if test="subCategory != null and subCategory != ''"> and sub_category=#{subCategory} </if></where>order by display_order asc</select> <select id="queryByMapId" resultMap="OnlyLayerResultMap" parameterType="long">select * from gms_map_layerwhere map_id=#{mapId}</select><select id="queryForTreeByMapId" resultMap="treeItemResultMap" parameterType="long">select l.id,l.name,'C_'||l.category as category,l.sub_category,min(s.min_zoom) as min_zoom,max(s.max_zoom) as max_zoomfrom gms_map_layer l,gms_map_layer_style swhere map_id=#{mapId} and l.id=s.map_layer_idand l.category not in ('40001') and l.name not in ('10001_176','10001_177','10001_178','20014_2')group by l.id,l.name,l.category,l.sub_categoryorder by l.category,l.sub_category</select><select id="queryByMapIdCategory" resultMap="OnlyLayerResultMap" >select * from gms_map_layerwhere map_id=#{mapId} and category=#{category}</select><select id="queryByIds" resultMap="resultMap">select * from gms_map_layerwhereid in<foreach item="item" index="index" collection="array" open="("separator="," close=")">#{item}</foreach></select><delete id="delete">delete from gms_map_layerwhere id = #{id}</delete><delete id="batchDelete">delete from gms_map_layerwhereid in<foreach item="item" index="index" collection="array" open="("separator="," close=")">#{item}</foreach></delete><update id="update">update gms_map_layer<set> <if test="id != null"> id=#{id}, </if> <if test="mapId != null"> map_id=#{mapId}, </if> <if test="layerId != null"> layer_id=#{layerId}, </if> <if test="name != null and name != ''"> name=#{name}, </if> <if test="hasIndex != null"> has_index=#{hasIndex}, </if> <if test="datasourceId != null"> datasource_id=#{datasourceId}, </if> <if test="displayOrder != null"> display_order=#{displayOrder}, </if> <if test="visible != null and visible != ''"> visible=#{visible}, </if> <if test="geoType != null"> geo_type=#{geoType}, </if> <if test="createTime != null"> create_time=#{createTime}, </if> <if test="updateTime != null"> update_time=#{updateTime}, </if> <if test="dataLayerName != null and dataLayerName != ''"> data_layer_name=#{dataLayerName}, </if> <if test="editable != null"> editable=#{editable}, </if> <if test="category != null and category != ''"> category=#{category}, </if> <if test="subCategory != null and subCategory != ''"> sub_category=#{subCategory}, </if></set>where id=#{id}</update><resultMap type="GmsMapLayer" id="resultMap"><!-- 用id属性来映射主键字段 --><id property="id" column="id" /> <result property="mapId" column="map_id" /> <result property="layerId" column="layer_id" /> <result property="name" column="name" /> <result property="hasIndex" column="has_index" /> <result property="datasourceId" column="datasource_id" /> <result property="displayOrder" column="display_order" /> <result property="geoType" column="geo_type" /> <result property="visible" column="visible" /> <result property="createTime" column="create_time" /> <result property="updateTime" column="update_time" /> <result property="dataLayerName" column="data_layer_name" /> <result property="editable" column="editable" /> <result property="category" column="category" /> <result property="subCategory" column="sub_category" /> <collection property="styles" column="id" ofType="GmsMapLayerStyle" select="GmsMapLayerStyleMapper.queryByMapLayerId"/></resultMap><resultMap type="TreeItem" id="treeItemResultMap"><!-- 用id属性来映射主键字段 --><id property="id" column="id" /> <result property="pId" column="category" /> <result property="name" column="name" /> <result property="minZoom" column="min_zoom" /> <result property="maxZoom" column="max_zoom" /> <result property="subCategory" column="sub_category" /></resultMap><resultMap type="GmsMapLayer" id="OnlyLayerResultMap"><!-- 用id属性来映射主键字段 --><id property="id" column="id" /> <result property="mapId" column="map_id" /> <result property="layerId" column="layer_id" /> <result property="name" column="name" /> <result property="hasIndex" column="has_index" /> <result property="datasourceId" column="datasource_id" /> <result property="displayOrder" column="display_order" /> <result property="geoType" column="geo_type" /> <result property="visible" column="visible" /> <result property="mapId" column="map_id" /> <result property="updateTime" column="update_time" /> <result property="dataLayerName" column="data_layer_name" /> <result property="editable" column="editable" /> <result property="category" column="category" /> <result property="subCategory" column="sub_category" /></resultMap><select id="indexFieldsByModelid" resultType="string">select columnname from gds_meta_field where modelid=#{modelid} and dbindex=1;</select><select id="mapNameByLayerId" resultType="string">select gm.name gm_name from gms_map_layer gl join gms_map gm on gl.map_id=gm.id where gl.layer_id=#{id};</select><select id="queryDetailByLayerid" resultMap="detailMap" parameterType="long">select gl.createdate gl_createdate,gl.id gl_id,gl.layername gl_name,gmf.id gmf_id,gmf.fieldtitle fieldTitle,gmf.fieldname fieldName,gmf.columnname columnName,gmf.fieldtype fieldType,gmf.fieldsize fieldSize,gmf.fieldinput fieldInput,gmf.fieldinputfilter fieldInputFilter,gmf.defaultvalue defaultValue,gmf.readonly readOnly,gmf.fieldorder fieldOrder,gmf.remark remark,gmf.dbindex dbindex,gmf.modelid modelid from gds_layer gl,gds_meta_field gmfwhere gl.modelid=gmf.modelid and gl.id=#{id};<!-- select gl.name,gm.name gm_name --><!-- from gms_map_layer gl --><!-- join gms_map gm --><!-- on gl.map_id=gm.id --><!-- where gl.layer_id=#{id}; --></select> <resultMap type="LayerDetail" id="detailMap"><result property="createDate" column="gl_createdate" /> <result property="name" column="gl_name" /><result property="id" column="gl_id" /><collection property="fields" ofType="GdsMetaField" javaType="list"><id property="id" column="gmf_id"/><result property="fieldTitle" column="fieldTitle"/><result property="modelId" column="modelid"/><result property="fieldName" column="fieldName"/><result property="columnName" column="columnName"/><result property="fieldType" column="fieldType"/><result property="fieldSize" column="fieldSize"/><result property="fieldInput" column="fieldInput"/><result property="fieldInputFilter" column="fieldInputFilter"/><result property="defaultValue" column="defaultValue"/><result property="readOnly" column="readOnly"/><result property="fieldOrder" column="fieldOrder"/><result property="remark" column="remark"/><result property="dbindex" column="dbindex"/></collection><collection property="indexFields" column="modelid=modelid" ofType="string" javaType="list" select="indexFieldsByModelid"><result property="columnname" column="columnname"/></collection><collection property="maps" ofType="String" column="id=gl_id" javaType="list" select="mapNameByLayerId" ><result property="name" column="gm_name"/></collection></resultMap></mapper>
0 0
- mybatis关联查询一对多问题解决,将表中对应的多条数据以list形式存储
- mybatis 关联数据的查询 多对一 一对多
- mybatis中如何查询一对多的关联列表数据
- Mybatis一对多关联查询
- mybatis一对多关联查询
- Mybatis一对多关联查询
- mybatis一对多关联查询
- MyBatis 一对多双向关联查询
- MyBatis-一对多关联表查询 -06
- mybatis 关联查询 一对一 一对多
- Mybatis入门--关联查询一对多
- mybatis一对多关联查询示例
- Mybatis一对多关联表查询
- MyBatis中一对多关联查询
- mybatis关联查询,一对一,一对多
- Mybatis一对一、一对多关联查询
- MyBatis一对多关联查询总结(五)
- mybatis多表(一对多关联查询)
- KMP(2)--hdu2594
- mybatis 批量的更新
- oracle 序列的创建和作用
- Fiddler (四) 实现手机的抓包
- DOS命令删除WINODOWS服务
- mybatis关联查询一对多问题解决,将表中对应的多条数据以list形式存储
- make_heap(), pop_heap(), push_heap()用法
- 如何快速开发出一个高质量的APP
- jhipster应用
- GitHub 翻译系列----入门(Hello World)
- make和Makefile中的规则和变量
- 圆形红点提示背景
- Hover-Z 日记-排名
- Fiddler (五) Mac下使用Fiddler