当前位置: 首页 > wzjs >正文

国外画册设计欣赏网站上海做网站去哪里

国外画册设计欣赏网站,上海做网站去哪里,个人网站设计论文道客巴巴,比汉斯设计网站素材本系列为笔者学习JavaWeb的课堂笔记,视频资源为B站黑马程序员出品的《黑马程序员JavaWeb开发教程,实现javaweb企业开发全流程(涵盖SpringMyBatisSpringMVCSpringBoot等)》,章节分布参考视频教程,为同样学习…

本系列为笔者学习JavaWeb的课堂笔记,视频资源为B站黑马程序员出品的《黑马程序员JavaWeb开发教程,实现javaweb企业开发全流程(涵盖Spring+MyBatis+SpringMVC+SpringBoot等)》,章节分布参考视频教程,为同样学习JavaWeb系列课程的同学们提供参考。

01 XML 映射文件

在这里插入图片描述

com/itheima/mapper

EmpMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.EmpMapper"><!--resultType:单条记录封装的类型--><select id="list" resultType="com.itheima.pojo.Emp"> ⭐⭐select * from emp where name like concat('%', '张', '%') and gender = #{gender} and entryDate between #{begin} and #{end} order by update_time desc</select>
</mapper>

MybatisX是一款基于IDEA的快速开发MybatisX的插件,用于提高效率。

注:使用Mybatis的注解,主要是来完成一些简单的增删改查功能。如果需要实现复杂的SQL功能,建议使用XML来配置映射语句。

02 动态 SQL

动态SQL为随着用户的输入或外部条件的变化而变化的SQL语句。

在这里插入图片描述

03 if 标签

<if>:通过test属性判断条件是否成立,成立为true,拼接SQL

<where>:在子元素有内容的情况下插入where子句,自动去除子句当中的andor

在这里插入图片描述

EmpMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.EmpMapper"> <!--resultType:单条记录封装的类型--><select id="list" resultType="com.itheima.pojo.Emp"> ⭐select * from emp<where><if test="name != null">name like concat('%', '张', '%')</if><if test="gender != null">and gender = #{gender}</if><if test="begin != null and end != null">and entryDate between #{begin} and #{end} </if></where>order by update_time desc</select>
</mapper>

注:and不能简单粗暴的删除,添加<where></where>标签对。

SpringbooyMybatisCrudApplicationTests.java

package com.itheima;import com.itheima.mapper.EmpMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;@SpringBootTest
class SpringbootMybatisCrudApplicationTests {@Autowiredprivate EmpMapper empMapper;@Testpublic void testList(){List<Emp> empList = empMapper.list("张", (short)1, null, null);System.out.println(empList);}
}

04 案例:动态更新员工数据信息

需求:动态更新员工信息,如果更新时传递有值,则更新,反之,则不更新。

解决方案:动态SQL

在这里插入图片描述

EmpMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.EmpMapper"> <update id="update2"> ⭐update emp <set> <if test="username != null">username=#{username},</if><if test="username != null">gender=#{gender},</if><if test="username != null">image=#{image}, </if><if test="username != null">job=#{job}, </if><if test="username != null">entrydate=#{entrydate},</if><if test="username != null">dept_id=#{deptId},</if><if test="username != null">updateTime=#{updateTime}</if></set>where id=#{id}</update>
</mapper>

注:,不能简单粗暴的删除,添加<set></set>标签对。

SpringbooyMybatisCrudApplicationTests.java

package com.itheima;import com.itheima.mapper.EmpMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;@SpringBootTest
class SpringbootMybatisCrudApplicationTests {@Autowiredprivate EmpMapper empMapper;@Testpublic void testUpdate(){Emp emp = new Emp();emp.setId(19); emp.setUsername("Tom222"); emp.setName("汤姆222");emp.setGender((short)1);emp.setUpdateTime(LocalDateTime.now());empMapper.update2(emp);}
}

05 foreach 标签

delete from emp where id in(18, 19, 20);

EmpMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.EmpMapper"> <!--批量删除员工 (13, 14, 15)--><delete id="deleteByIds"> ⭐delete from emp where id in<foreach collection="ids" item="id" separator="," open="(" close=")">#{id}</foreach></delete> 
</mapper>

connection:遍历的集合

item:遍历出来的元素

separation:分隔符

open:遍历开始前拼接的SQL片段

close:遍历开始后拼接的SQL片段

SpringbooyMybatisCrudApplicationTests.java

package com.itheima;import com.itheima.mapper.EmpMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;@SpringBootTest
class SpringbootMybatisCrudApplicationTests {@Autowiredprivate EmpMapper empMapper;@Testpublic void testDeleteByIds(){List<Integer> ids = Arrays.asList(13, 14, 15); //构造List集合empMapper.deleteByIds(ids);}
}

在这里插入图片描述

在这里插入图片描述

注:不要忘了接口方法哦~

06 sql & include 标签

在这里插入图片描述

EmpMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.EmpMapper"> <sql id="commonSelect"> ⭐select username, name, gender, image, job, entrydate, dept_id, create_time, update_time from emp</sql><select id="list" resultType="com.itheima.pojo.Emp"><include refid="commonSelect"/> ⭐from emp<where><if test="name != null">name like concat('%', '张', '%')</if><if test="gender != null">and gender = #{gender}</if><if test="begin != null and end != null">and entryDate between #{begin} and #{end} </if></where>order by undate_time desc</select>
</mapper>

<sql>:定义可重用的SQL片段

<include>:通过属性refid,指定包含的SQL片段


文章转载自:

http://hrcBw8BO.qrpdk.cn
http://G2q18wab.qrpdk.cn
http://FpcRdhPN.qrpdk.cn
http://0Z0jxblv.qrpdk.cn
http://CxEbXbKj.qrpdk.cn
http://7g1ABQ4n.qrpdk.cn
http://LMwmRxnZ.qrpdk.cn
http://9Kl3cytw.qrpdk.cn
http://pTvlyYcK.qrpdk.cn
http://uVdcE3oW.qrpdk.cn
http://U8pq2V1l.qrpdk.cn
http://y66EOd3v.qrpdk.cn
http://bNaW35iY.qrpdk.cn
http://jZCdB4S0.qrpdk.cn
http://rEi0iEa2.qrpdk.cn
http://GpNPjP4h.qrpdk.cn
http://5q5yFc4f.qrpdk.cn
http://ABWhzqfb.qrpdk.cn
http://WKaCUD4n.qrpdk.cn
http://bc82tokP.qrpdk.cn
http://LxHJfGe7.qrpdk.cn
http://y6hUbFjs.qrpdk.cn
http://ArOWTEcU.qrpdk.cn
http://M5QkXYHF.qrpdk.cn
http://n7Hs05Zu.qrpdk.cn
http://Wwodkfbl.qrpdk.cn
http://dgW4VGOQ.qrpdk.cn
http://ib7c9FpI.qrpdk.cn
http://HC6xM6vQ.qrpdk.cn
http://WcWELnUY.qrpdk.cn
http://www.dtcms.com/wzjs/678340.html

相关文章:

  • h5自适应网站模板西昌市建设工程管理局网站
  • 网站上传的流程图网站流量统计表
  • 天河做网站哪家好广东专业商城网站建设
  • 彩票网站开发合法吗网络优化大师下载
  • 质量好网站建设公司做医院网站公司电话
  • 网站做链接的意义是什么v2ex wordpress主题
  • 公司微网站制作克隆网站怎么做后台
  • 专业网站建设哪里找泉州网站建设解决方案
  • 建筑作品集网站代做外包制作app软件要多少钱
  • win7和wordpress博客seo怎么做
  • 平凉市住房和城乡建设局网站扬中网站建设包括哪些
  • 外贸建站哪家公司好seo网站的锚文本怎么写
  • 安徽建设厅网站施网站建设源代码共享
  • 学做网站需要多久时间购物网站每个模块主要功能
  • 做旅游网站的目的是什么备案 手机网站
  • 站长之家网站建设制作西安市建设工程
  • 网站开发工作经验怎么写html网页搭建
  • 广州管网建设小江seo
  • 下载站推广正规网站建设报价
  • 衡水淘宝的网站建设杭州滨江网站建设公司
  • seo网站优化方建设公司网站征集信息的通知
  • 免费制作网站的基本流程辽宁网络科技有限公司
  • 怎么办个人网站室内装饰设计平面图
  • 四平网站建设在线咨询广州市网站公司
  • 福州微信网站开发wordpress 分类目录 文章
  • 网站建设讲话二级建造师报名的官网
  • 网站地图怎么做XML做电影网站要怎么样的主机
  • 中山 网站设计wordpress 树 插件
  • 即墨网站开发做网站和做app的区别
  • go语言做网站品牌设计师工资一般多少