摘要: <mapper namespace="接口路径"> <resultMap id="名称1" type="映射类名"> <id column="id" property="id"/> <result column="user_id" property="userId"/> <result column 阅读全文
posted @ 2021-11-21 16:11 智慧搬运工 阅读(53) 评论(0) 推荐(0)
摘要: 原本的sql语句执行:select * from 表单 ,这种方式会获取表中所有字段,项目大时会特别的慢<select id="selectById" resultType="Video" parameterType="INTEGER"> select * from video where id=# 阅读全文
posted @ 2021-11-20 16:16 智慧搬运工 阅读(218) 评论(0) 推荐(0)
摘要: 在mybatis的配置文件中添加 <typeAliases><!-- <typeAlias type="com.example.demo01.domain.Video" alias="Video"/>--> //让类取别名 一个个配置,如果有很多个类,可以使用下面这行,包扫描 <package na 阅读全文
posted @ 2021-11-20 15:50 智慧搬运工 阅读(26) 评论(0) 推荐(0)
摘要: <!--删除一条数据--><delete id="方法名" parameterType="<!--传入一个MAP-->java.util.Map" > delete from video where title like concat('%',#{title},'%') and price <![C 阅读全文
posted @ 2021-11-19 23:37 智慧搬运工 阅读(84) 评论(0) 推荐(0)
摘要: <!--动态字段更新 if test 标签使用--><update id="方法名" parameterType="类对象的路径"> update video <trim prefix="set" suffixOverrides=","> <if test="title != null">title 阅读全文
posted @ 2021-11-19 21:49 智慧搬运工 阅读(468) 评论(0) 推荐(0)
摘要: <update id="接口的方法名" parameterType="类对象的路径">//sql语句 update video set title=#{title,jdbcType=VARCHAR}, detail=#{detail,jdbcType=VARCHAR}, cover_img=#{co 阅读全文
posted @ 2021-11-19 11:28 智慧搬运工 阅读(71) 评论(0) 推荐(0)
摘要: 在xml文件中添加红框代码 keyProperty指数据库表中的自增主键 keyColum指映射的类中的属性名称 上代码: <insert id="add" parameterType="com.example.demo01.domain.Video" useGeneratedKeys="true" 阅读全文
posted @ 2021-11-19 10:34 智慧搬运工 阅读(130) 评论(0) 推荐(0)
摘要: mybatis配置文件内代码 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybat 阅读全文
posted @ 2021-11-18 23:06 智慧搬运工 阅读(37) 评论(0) 推荐(0)