2 qq 24179109 qq_24179109 于 2017.01.10 11:51 提问

怎样实现单MyBatis单表查询 1C

图片说明这是数据库关系表,就一张表,INDUS对应多个THEME,每个THEME对应多个LABEL,每个Label对应多个KPI,求帮忙了,谢谢,我只要大概的思路 项目的框架用的Springmvc +myBatis
java的Service层怎么给集合排序,MyBatis的xml怎么写sql呢,要求用一个集合返回所有数据图片说明

12个回答

qq_24179109
qq_24179109   2017.01.10 12:01

图片说明

engchina
engchina   Rxr 2017.01.10 12:06

如果你是用的IDE是eclipse的话,可以安装mybatis generator自动生成sql文。

mybatis generator plugin下载地址
https://github.com/mybatis/generator

mybatis generator怎么使用和写sql下面文章可以参考。
http://blog.csdn.net/engchina/article/details/48780373
http://blog.csdn.net/engchina/article/details/49028155
http://blog.csdn.net/engchina/article/details/49028995

JE_GE
JE_GE   2017.01.10 12:40


select * from student

JE_GE
JE_GE   2017.01.10 12:40
 <!-- 查询所有的记录 -->
 <select id="findAll" resultMap="studentResultMap">
  select * from student
 </select>
javaee_sunny
javaee_sunny   2017.01.10 14:25

要想用一个集合返回所有数据.我的意见是:(1)创建一个与该表对应的model类;(2)编写sql.xml文件,将查询结果封装到model集合中.

u014266877
u014266877   2017.01.10 17:12

镇楼

SELECT
USER.UserId, USER.UserName, ROLE.RoleName, USER.Status,
USER.AddTime, USER.Mobile,
USER.Email, ROLE.RoleId, USER.Password,
USER.UserCode,
POST.post_id,POST.post_name,DEMP.department_id,DEMP.department_name,POS.position_name,POS.position_id, USER.IsLock
FROM sys_user USER LEFT JOIN sys_role ROLE ON USER.RoleId =
ROLE.RoleId LEFT JOIN crm_post POST ON USER.PostId = POST.post_id
LEFT
JOIN crm_department DEMP ON POST.department_id = DEMP.department_id
LEFT JOIN crm_position POS ON POST.position_id = POS.position_id WHERE
1 = 1

AND USER.UserId = #{UserId}


AND ROLE.RoleId = #{RoleId}


AND ROLE.RoleName = #{RoleName}


AND ROLE.RoleName != '超级管理员'


AND USER.Password = #{Password}


AND USER.Tel = #{Tel}


AND USER.IsDelete = #{IsDelete}


AND USER.UserCode LIKE CONCAT('%',CONCAT(#{UserCode},'%'))


AND USER.Status = #{Status}


AND USER.UserCode = #{Mobile}


AND USER.PostId = #{post_id}


AND USER.IsLock = #{IsLock}

AND USER.IsDelete = 1 order by USER.AddTime desc limit #{start},#{end}


u014266877
u014266877   2017.01.10 17:13


SELECT USER.UserId, USER.UserName, USER.RoleId, USER.UserCode
FROM sys_user USER WHERE 1 = 1

AND USER.UserCode = #{UserCode}


u014266877
u014266877   2017.01.10 17:14


SELECT USER.UserId, USER.UserName, USER.RoleId, USER.UserCode
FROM sys_user USER WHERE 1 = 1

AND USER.UserCode = #{UserCode}

u014266877
u014266877   2017.01.10 17:14

||

CodeFarmerCXY
CodeFarmerCXY   2017.01.10 19:32
共12条数据 1 尾页
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!