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

做购物网站开发价格天津百度网站排名优化

做购物网站开发价格,天津百度网站排名优化,做网站需要自己研发吗,贵阳网站建设q.479185700棒目录 前言 1.准备工作 1.1⽂件配置 1.2添加 mapper 接⼝ 2.增删改查操作 2.1增(Insert) 2.2删(Delete) 2.3改(Update) 2.4查(Select) 前言 接下来我们会使用的数据表如下: 对应的实体类为:UserInfo 所有的准备工作都在如下文章。 MyBatis 操作…

目录

前言

1.准备工作

1.1⽂件配置

1.2添加 mapper 接⼝

2.增删改查操作

2.1增(Insert)

 2.2删(Delete)

2.3改(Update)

2.4查(Select)


前言

 接下来我们会使用的数据表如下:

对应的实体类为:UserInfo

所有的准备工作都在如下文章。

MyBatis 操作数据库入门-CSDN博客文章浏览阅读568次,点赞11次,收藏24次。什么是MyBatis?MyBatis是⼀款优秀的 持久层 框架,⽤于简化JDBC的开发Mybatis操作数据库的入门步骤:1.创建springboot⼯程2.数据库表准备、实体类3.引⼊Mybatis的相关依赖,配置Mybatis(数据库连接信息)4.编写SQL语句(注解/XML) ,进行测试了解更多MyBatis中文网1.创建springboot⼯程创建springboot⼯程,并导⼊ mybatis的起步依赖、mysql的驱动包。https://blog.csdn.net/WHabc2002/article/details/142743762


1.准备工作

1.1⽂件配置

如果是application.yml⽂件, 配置内容如下:

mybatis:mapper-locations: classpath:mybatis/**Mapper.xml

 如果是application.properties⽂件, 配置内容如下:

mybatis.mapper-locations=classpath:mapper/**Mapper.xml

 按照mybatis.mapper-locations设置文件

起名无所谓最后以Mapper.xml结尾就行 

1.2添加 mapper 接⼝

 数据持久层的接⼝定义:(接口名自已决定)

import com.wh.myBatis.model.UserInfo;
import org.apache.ibatis.annotations.Mapper;import java.util.List;@Mapper
public interface UserInfoXmlMapper {List<UserInfo> selectAllUser();
}

1.3添加MyBatis 的固定 xml 格式

mybatis.mapper-locations的路径下

 

MyBatis 的固定 xml 格式

以我为例:

<?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="com.wh.myBatis.mapper.UserInfoXmlMapper"></mapper>

路径一定要正确 


2.增删改查操作

为了增加开发效率,我们可以使用插件。

2.1增(Insert)

UserInfoXmlMapper接口
Integer insert(UserInfo userInfo);

UserInfoXmlMapper.xml的实现

<?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="com.wh.myBatis.mapper.UserInfoXmlMapper"><insert id="insert">insert into userinfo (username, password, age, gender)values (#{username},#{password},#{age},#{gender})</insert>
</mapper>

 如果使⽤@Param设置参数名称的话, 使⽤⽅法和注解类似

返回⾃增 id
接⼝定义不变, UserInfoXmlMapper.xml 实现 设置useGeneratedKeys 和keyProperty属性
    <insert id="insert2" useGeneratedKeys="true" keyProperty="id">insert into userinfo (username, password, age, gender)values (#{username},#{password},#{age},#{gender})</insert>

 2.2删(Delete)

UserInfoXmlMapper接口

Integer delete(Integer id);

 UserInfoXmlMapper.xml的实现

<delete id="delete">delete from userinfo where id = #{id}</delete>

2.3改(Update)

UserInfoXmlMapper接口

Integer update(UserInfo userInfo);

 UserInfoXmlMapper.xml的实现

  <update id="update">update userinfo set username=#{username} where id=#{id}</update>

2.4查(Select)

UserInfoXmlMapper接口

List<UserInfo> selectAllUser();

UserInfoXmlMapper.xml的实现

    <select id="selectAllUser" resultType="com.wh.myBatis.model.UserInfo">select * from userinfo</select>

 MyBatis 会获取结果中返回的列名并在 Java 类中查找相同名字的属性 

 小驼峰与蛇形的结果映射

 UserInfoXmlMapper.xml的实现

    <resultMap id="BaseMap" type="com.wh.myBatis.model.UserInfo"><id column="id" property="id"></id><result column="delete_flag" property="deleteFlag"></result><result column="create_time" property="createTime"></result><result column="update_time" property="updateTime"></result></resultMap><select id="selectAllUser2" resultMap="BaseMap">select * from userinfo</select>


以上为我个人的小分享,如有问题,欢迎讨论!!! 

都看到这了,不如关注一下,给个免费的赞 

http://www.hkea.cn/news/891679/

相关文章:

  • wordpress icomoon太原seo快速排名
  • 中华建设杂志网站记者数据指数
  • 网站开发测试情况南召seo快速排名价格
  • 上海仓储公司小红书seo优化
  • 南京建设公司网站网络营销整合推广
  • wordpress更改语言沈阳seo优化
  • wordpress免费网站世界大学排名
  • 做网站的属于什么专业?百度爱采购竞价推广
  • 网站建设一年多少恰东莞网站到首页排名
  • 新企业网站应该怎么做SEO优化广告联盟有哪些
  • 手机app开发网站建设软文推广文章案例
  • 网站自然排名百度经验官网登录
  • dz网站模板沧州网站优化公司
  • 桂林论坛天涯社区培训行业seo整站优化
  • 做伊瑞尔竞技场的网站搜索引擎简称seo
  • 46云虚拟主机股票发行ipo和seo是什么意思
  • 新泰做网站菏泽seo
  • 网站建设排名东莞seo收费
  • 做网站前后端的发布流程自己如何制作网站
  • 网站营销与推广策略百度一下官网首页百度
  • 网站建设张世勇100个免费推广b站
  • 网络营销的常用工具百度关键词优化点击 教程
  • 公司网站要怎么做少儿编程培训机构排名前十
  • 一个好的网站是什么样的商家联盟营销方案
  • 网站解除域名绑定网站广告收费标准
  • 郑州的建设网站有哪些手续免费发布推广信息的平台有哪些
  • 手机做网站软件优化服务平台
  • 网站图片装修的热切图怎么做营销技巧培训
  • 可以上传图片的网站怎么做百度关键词点击
  • 泉州网站制作广州seo网站开发