pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>top.qaqaq.mybatis</groupId>
<artifactId>MyBatis_MBG</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyBatis_MBG</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- 依赖MyBatis核心包 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.7</version>
</dependency>
<!-- junit测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- MySQL驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.31</version>
</dependency>
<!-- log4j日志 -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<!-- 控制Maven在构建过程中相关配置 -->
<build>
<!-- 构建过程中用到的插件 -->
<plugins>
<!-- 具体插件,逆向工程的操作是以构建过程中插件形式出现的 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.0</version>
<!-- 插件的依赖 -->
<dependencies>
<!-- 逆向工程的核心依赖 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>
<!-- 数据库连接池 -->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.2</version>
</dependency>
<!-- MySQL驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.31</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
resources
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties resource="jdbc.properties"/>
<typeAliases>
<package name="top.qaqaq.mybatis.pojo"/>
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</dataSource>
</environment>
</environments>
<mappers>
<package name="top.qaqaq.mybatis.mapper"/>
</mappers>
</configuration>
jdbc.properties
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mybatis
jdbc.username=root
jdbc.password=123456
log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<param name="Encoding" value="UTF-8" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %d{MM-dd HH:mm:ss,SSS}%m (%F:%L) \n" />
</layout>
</appender>
<logger name="java.sql">
<level value="debug" />
</logger>
<logger name="org.apache.ibatis">
<level value="info" />
</logger>
<root>
<level value="debug" />
<appender-ref ref="STDOUT" />
</root>
</log4j:configuration>
generatorConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--
targetRuntime: 执行生成的逆向工程的版本
MyBatis3Simple: 生成基本的CRUD(清新简洁版)
MyBatis3: 生成带条件的CRUD(奢华尊享版)
-->
<context id="DB2Tables" targetRuntime="MyBatis3">
<!-- 数据库的连接信息 -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/mybatis"
userId="root"
password="123456">
</jdbcConnection>
<!-- javaBean的生成策略-->
<javaModelGenerator targetPackage="top.qaqaq.mybatis.pojo" targetProject=".\src\main\java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- SQL映射文件的生成策略 -->
<sqlMapGenerator targetPackage="top.qaqaq.mybatis.mapper" targetProject=".\src\main\resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- Mapper接口的生成策略 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="top.qaqaq.mybatis.mapper" targetProject=".\src\main\java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 逆向分析的表 -->
<!-- tableName设置为*号,可以对应所有表,此时不写domainObjectName -->
<!-- domainObjectName属性指定生成出来的实体类的类名 -->
<table tableName="t_emp" domainObjectName="Emp"/>
<table tableName="t_dept" domainObjectName="Dept"/>
</context>
</generatorConfiguration>
resources/mapper
EmpMapper .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="top.qaqaq.mybatis.mapper.EmpMapper" >
<resultMap id="BaseResultMap" type="top.qaqaq.mybatis.pojo.Emp" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
<id column="eid" property="eid" jdbcType="INTEGER" />
<result column="emp_name" property="empName" jdbcType="VARCHAR" />
<result column="age" property="age" jdbcType="INTEGER" />
<result column="sex" property="sex" jdbcType="CHAR" />
<result column="email" property="email" jdbcType="VARCHAR" />
<result column="did" property="did" jdbcType="INTEGER" />
</resultMap>
<sql id="Example_Where_Clause" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
<where >
<foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
eid, emp_name, age, sex, email, did
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="top.qaqaq.mybatis.pojo.EmpExample" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from t_emp
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
select
<include refid="Base_Column_List" />
from t_emp
where eid = #{eid,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
delete from t_emp
where eid = #{eid,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="top.qaqaq.mybatis.pojo.EmpExample" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
delete from t_emp
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="top.qaqaq.mybatis.pojo.Emp" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
insert into t_emp (eid, emp_name, age,
sex, email, did)
values (#{eid,jdbcType=INTEGER}, #{empName,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER},
#{sex,jdbcType=CHAR}, #{email,jdbcType=VARCHAR}, #{did,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="top.qaqaq.mybatis.pojo.Emp" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
insert into t_emp
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="eid != null" >
eid,
</if>
<if test="empName != null" >
emp_name,
</if>
<if test="age != null" >
age,
</if>
<if test="sex != null" >
sex,
</if>
<if test="email != null" >
email,
</if>
<if test="did != null" >
did,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="eid != null" >
#{eid,jdbcType=INTEGER},
</if>
<if test="empName != null" >
#{empName,jdbcType=VARCHAR},
</if>
<if test="age != null" >
#{age,jdbcType=INTEGER},
</if>
<if test="sex != null" >
#{sex,jdbcType=CHAR},
</if>
<if test="email != null" >
#{email,jdbcType=VARCHAR},
</if>
<if test="did != null" >
#{did,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="top.qaqaq.mybatis.pojo.EmpExample" resultType="java.lang.Integer" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
select count(*) from t_emp
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
update t_emp
<set >
<if test="record.eid != null" >
eid = #{record.eid,jdbcType=INTEGER},
</if>
<if test="record.empName != null" >
emp_name = #{record.empName,jdbcType=VARCHAR},
</if>
<if test="record.age != null" >
age = #{record.age,jdbcType=INTEGER},
</if>
<if test="record.sex != null" >
sex = #{record.sex,jdbcType=CHAR},
</if>
<if test="record.email != null" >
email = #{record.email,jdbcType=VARCHAR},
</if>
<if test="record.did != null" >
did = #{record.did,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
update t_emp
set eid = #{record.eid,jdbcType=INTEGER},
emp_name = #{record.empName,jdbcType=VARCHAR},
age = #{record.age,jdbcType=INTEGER},
sex = #{record.sex,jdbcType=CHAR},
email = #{record.email,jdbcType=VARCHAR},
did = #{record.did,jdbcType=INTEGER}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="top.qaqaq.mybatis.pojo.Emp" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
update t_emp
<set >
<if test="empName != null" >
emp_name = #{empName,jdbcType=VARCHAR},
</if>
<if test="age != null" >
age = #{age,jdbcType=INTEGER},
</if>
<if test="sex != null" >
sex = #{sex,jdbcType=CHAR},
</if>
<if test="email != null" >
email = #{email,jdbcType=VARCHAR},
</if>
<if test="did != null" >
did = #{did,jdbcType=INTEGER},
</if>
</set>
where eid = #{eid,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="top.qaqaq.mybatis.pojo.Emp" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
update t_emp
set emp_name = #{empName,jdbcType=VARCHAR},
age = #{age,jdbcType=INTEGER},
sex = #{sex,jdbcType=CHAR},
email = #{email,jdbcType=VARCHAR},
did = #{did,jdbcType=INTEGER}
where eid = #{eid,jdbcType=INTEGER}
</update>
</mapper>
DeptMapper.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="top.qaqaq.mybatis.mapper.DeptMapper" >
<resultMap id="BaseResultMap" type="top.qaqaq.mybatis.pojo.Dept" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
<id column="did" property="did" jdbcType="INTEGER" />
<result column="dept_name" property="deptName" jdbcType="VARCHAR" />
</resultMap>
<sql id="Example_Where_Clause" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
<where >
<foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
did, dept_name
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="top.qaqaq.mybatis.pojo.DeptExample" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from t_dept
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
select
<include refid="Base_Column_List" />
from t_dept
where did = #{did,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
delete from t_dept
where did = #{did,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="top.qaqaq.mybatis.pojo.DeptExample" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
delete from t_dept
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="top.qaqaq.mybatis.pojo.Dept" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
insert into t_dept (did, dept_name)
values (#{did,jdbcType=INTEGER}, #{deptName,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="top.qaqaq.mybatis.pojo.Dept" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
insert into t_dept
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="did != null" >
did,
</if>
<if test="deptName != null" >
dept_name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="did != null" >
#{did,jdbcType=INTEGER},
</if>
<if test="deptName != null" >
#{deptName,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="top.qaqaq.mybatis.pojo.DeptExample" resultType="java.lang.Integer" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
select count(*) from t_dept
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
update t_dept
<set >
<if test="record.did != null" >
did = #{record.did,jdbcType=INTEGER},
</if>
<if test="record.deptName != null" >
dept_name = #{record.deptName,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
update t_dept
set did = #{record.did,jdbcType=INTEGER},
dept_name = #{record.deptName,jdbcType=VARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="top.qaqaq.mybatis.pojo.Dept" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
update t_dept
<set >
<if test="deptName != null" >
dept_name = #{deptName,jdbcType=VARCHAR},
</if>
</set>
where did = #{did,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="top.qaqaq.mybatis.pojo.Dept" >
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jan 04 16:17:13 CST 2023.
-->
update t_dept
set dept_name = #{deptName,jdbcType=VARCHAR}
where did = #{did,jdbcType=INTEGER}
</update>
</mapper>
mapper
EmpMapper .java(自动生成)
package top.qaqaq.mybatis.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import top.qaqaq.mybatis.pojo.Emp;
import top.qaqaq.mybatis.pojo.EmpExample;
public interface EmpMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int countByExample(EmpExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int deleteByExample(EmpExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int deleteByPrimaryKey(Integer eid);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int insert(Emp record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int insertSelective(Emp record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
List<Emp> selectByExample(EmpExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
Emp selectByPrimaryKey(Integer eid);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int updateByExampleSelective(@Param("record") Emp record, @Param("example") EmpExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int updateByExample(@Param("record") Emp record, @Param("example") EmpExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int updateByPrimaryKeySelective(Emp record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int updateByPrimaryKey(Emp record);
}
DeptMapper .java(自动生成)
package top.qaqaq.mybatis.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import top.qaqaq.mybatis.pojo.Dept;
import top.qaqaq.mybatis.pojo.DeptExample;
public interface DeptMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int countByExample(DeptExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int deleteByExample(DeptExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int deleteByPrimaryKey(Integer did);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int insert(Dept record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int insertSelective(Dept record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
List<Dept> selectByExample(DeptExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
Dept selectByPrimaryKey(Integer did);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int updateByExampleSelective(@Param("record") Dept record, @Param("example") DeptExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int updateByExample(@Param("record") Dept record, @Param("example") DeptExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int updateByPrimaryKeySelective(Dept record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
int updateByPrimaryKey(Dept record);
}
pojo
Emp .java(自动生成)
package top.qaqaq.mybatis.pojo;
public class Emp {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column t_emp.eid
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
private Integer eid;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column t_emp.emp_name
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
private String empName;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column t_emp.age
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
private Integer age;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column t_emp.sex
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
private String sex;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column t_emp.email
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
private String email;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column t_emp.did
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
private Integer did;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column t_emp.eid
*
* @return the value of t_emp.eid
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public Integer getEid() {
return eid;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column t_emp.eid
*
* @param eid the value for t_emp.eid
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setEid(Integer eid) {
this.eid = eid;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column t_emp.emp_name
*
* @return the value of t_emp.emp_name
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public String getEmpName() {
return empName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column t_emp.emp_name
*
* @param empName the value for t_emp.emp_name
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setEmpName(String empName) {
this.empName = empName == null ? null : empName.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column t_emp.age
*
* @return the value of t_emp.age
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public Integer getAge() {
return age;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column t_emp.age
*
* @param age the value for t_emp.age
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setAge(Integer age) {
this.age = age;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column t_emp.sex
*
* @return the value of t_emp.sex
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public String getSex() {
return sex;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column t_emp.sex
*
* @param sex the value for t_emp.sex
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setSex(String sex) {
this.sex = sex == null ? null : sex.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column t_emp.email
*
* @return the value of t_emp.email
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public String getEmail() {
return email;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column t_emp.email
*
* @param email the value for t_emp.email
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setEmail(String email) {
this.email = email == null ? null : email.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column t_emp.did
*
* @return the value of t_emp.did
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public Integer getDid() {
return did;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column t_emp.did
*
* @param did the value for t_emp.did
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setDid(Integer did) {
this.did = did;
}
public Emp() {
}
public Emp(Integer eid, String empName, Integer age, String sex, String email, Integer did) {
this.eid = eid;
this.empName = empName;
this.age = age;
this.sex = sex;
this.email = email;
this.did = did;
}
@Override
public String toString() {
return "Emp{" +
"eid=" + eid +
", empName='" + empName + '\'' +
", age=" + age +
", sex='" + sex + '\'' +
", email='" + email + '\'' +
", did=" + did +
'}';
}
}
EmpExample.java(自动生成)
package top.qaqaq.mybatis.pojo;
import java.util.ArrayList;
import java.util.List;
public class EmpExample {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected String orderByClause;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected boolean distinct;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected List<Criteria> oredCriteria;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public EmpExample() {
oredCriteria = new ArrayList<Criteria>();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public String getOrderByClause() {
return orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public boolean isDistinct() {
return distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andEidIsNull() {
addCriterion("eid is null");
return (Criteria) this;
}
public Criteria andEidIsNotNull() {
addCriterion("eid is not null");
return (Criteria) this;
}
public Criteria andEidEqualTo(Integer value) {
addCriterion("eid =", value, "eid");
return (Criteria) this;
}
public Criteria andEidNotEqualTo(Integer value) {
addCriterion("eid <>", value, "eid");
return (Criteria) this;
}
public Criteria andEidGreaterThan(Integer value) {
addCriterion("eid >", value, "eid");
return (Criteria) this;
}
public Criteria andEidGreaterThanOrEqualTo(Integer value) {
addCriterion("eid >=", value, "eid");
return (Criteria) this;
}
public Criteria andEidLessThan(Integer value) {
addCriterion("eid <", value, "eid");
return (Criteria) this;
}
public Criteria andEidLessThanOrEqualTo(Integer value) {
addCriterion("eid <=", value, "eid");
return (Criteria) this;
}
public Criteria andEidIn(List<Integer> values) {
addCriterion("eid in", values, "eid");
return (Criteria) this;
}
public Criteria andEidNotIn(List<Integer> values) {
addCriterion("eid not in", values, "eid");
return (Criteria) this;
}
public Criteria andEidBetween(Integer value1, Integer value2) {
addCriterion("eid between", value1, value2, "eid");
return (Criteria) this;
}
public Criteria andEidNotBetween(Integer value1, Integer value2) {
addCriterion("eid not between", value1, value2, "eid");
return (Criteria) this;
}
public Criteria andEmpNameIsNull() {
addCriterion("emp_name is null");
return (Criteria) this;
}
public Criteria andEmpNameIsNotNull() {
addCriterion("emp_name is not null");
return (Criteria) this;
}
public Criteria andEmpNameEqualTo(String value) {
addCriterion("emp_name =", value, "empName");
return (Criteria) this;
}
public Criteria andEmpNameNotEqualTo(String value) {
addCriterion("emp_name <>", value, "empName");
return (Criteria) this;
}
public Criteria andEmpNameGreaterThan(String value) {
addCriterion("emp_name >", value, "empName");
return (Criteria) this;
}
public Criteria andEmpNameGreaterThanOrEqualTo(String value) {
addCriterion("emp_name >=", value, "empName");
return (Criteria) this;
}
public Criteria andEmpNameLessThan(String value) {
addCriterion("emp_name <", value, "empName");
return (Criteria) this;
}
public Criteria andEmpNameLessThanOrEqualTo(String value) {
addCriterion("emp_name <=", value, "empName");
return (Criteria) this;
}
public Criteria andEmpNameLike(String value) {
addCriterion("emp_name like", value, "empName");
return (Criteria) this;
}
public Criteria andEmpNameNotLike(String value) {
addCriterion("emp_name not like", value, "empName");
return (Criteria) this;
}
public Criteria andEmpNameIn(List<String> values) {
addCriterion("emp_name in", values, "empName");
return (Criteria) this;
}
public Criteria andEmpNameNotIn(List<String> values) {
addCriterion("emp_name not in", values, "empName");
return (Criteria) this;
}
public Criteria andEmpNameBetween(String value1, String value2) {
addCriterion("emp_name between", value1, value2, "empName");
return (Criteria) this;
}
public Criteria andEmpNameNotBetween(String value1, String value2) {
addCriterion("emp_name not between", value1, value2, "empName");
return (Criteria) this;
}
public Criteria andAgeIsNull() {
addCriterion("age is null");
return (Criteria) this;
}
public Criteria andAgeIsNotNull() {
addCriterion("age is not null");
return (Criteria) this;
}
public Criteria andAgeEqualTo(Integer value) {
addCriterion("age =", value, "age");
return (Criteria) this;
}
public Criteria andAgeNotEqualTo(Integer value) {
addCriterion("age <>", value, "age");
return (Criteria) this;
}
public Criteria andAgeGreaterThan(Integer value) {
addCriterion("age >", value, "age");
return (Criteria) this;
}
public Criteria andAgeGreaterThanOrEqualTo(Integer value) {
addCriterion("age >=", value, "age");
return (Criteria) this;
}
public Criteria andAgeLessThan(Integer value) {
addCriterion("age <", value, "age");
return (Criteria) this;
}
public Criteria andAgeLessThanOrEqualTo(Integer value) {
addCriterion("age <=", value, "age");
return (Criteria) this;
}
public Criteria andAgeIn(List<Integer> values) {
addCriterion("age in", values, "age");
return (Criteria) this;
}
public Criteria andAgeNotIn(List<Integer> values) {
addCriterion("age not in", values, "age");
return (Criteria) this;
}
public Criteria andAgeBetween(Integer value1, Integer value2) {
addCriterion("age between", value1, value2, "age");
return (Criteria) this;
}
public Criteria andAgeNotBetween(Integer value1, Integer value2) {
addCriterion("age not between", value1, value2, "age");
return (Criteria) this;
}
public Criteria andSexIsNull() {
addCriterion("sex is null");
return (Criteria) this;
}
public Criteria andSexIsNotNull() {
addCriterion("sex is not null");
return (Criteria) this;
}
public Criteria andSexEqualTo(String value) {
addCriterion("sex =", value, "sex");
return (Criteria) this;
}
public Criteria andSexNotEqualTo(String value) {
addCriterion("sex <>", value, "sex");
return (Criteria) this;
}
public Criteria andSexGreaterThan(String value) {
addCriterion("sex >", value, "sex");
return (Criteria) this;
}
public Criteria andSexGreaterThanOrEqualTo(String value) {
addCriterion("sex >=", value, "sex");
return (Criteria) this;
}
public Criteria andSexLessThan(String value) {
addCriterion("sex <", value, "sex");
return (Criteria) this;
}
public Criteria andSexLessThanOrEqualTo(String value) {
addCriterion("sex <=", value, "sex");
return (Criteria) this;
}
public Criteria andSexLike(String value) {
addCriterion("sex like", value, "sex");
return (Criteria) this;
}
public Criteria andSexNotLike(String value) {
addCriterion("sex not like", value, "sex");
return (Criteria) this;
}
public Criteria andSexIn(List<String> values) {
addCriterion("sex in", values, "sex");
return (Criteria) this;
}
public Criteria andSexNotIn(List<String> values) {
addCriterion("sex not in", values, "sex");
return (Criteria) this;
}
public Criteria andSexBetween(String value1, String value2) {
addCriterion("sex between", value1, value2, "sex");
return (Criteria) this;
}
public Criteria andSexNotBetween(String value1, String value2) {
addCriterion("sex not between", value1, value2, "sex");
return (Criteria) this;
}
public Criteria andEmailIsNull() {
addCriterion("email is null");
return (Criteria) this;
}
public Criteria andEmailIsNotNull() {
addCriterion("email is not null");
return (Criteria) this;
}
public Criteria andEmailEqualTo(String value) {
addCriterion("email =", value, "email");
return (Criteria) this;
}
public Criteria andEmailNotEqualTo(String value) {
addCriterion("email <>", value, "email");
return (Criteria) this;
}
public Criteria andEmailGreaterThan(String value) {
addCriterion("email >", value, "email");
return (Criteria) this;
}
public Criteria andEmailGreaterThanOrEqualTo(String value) {
addCriterion("email >=", value, "email");
return (Criteria) this;
}
public Criteria andEmailLessThan(String value) {
addCriterion("email <", value, "email");
return (Criteria) this;
}
public Criteria andEmailLessThanOrEqualTo(String value) {
addCriterion("email <=", value, "email");
return (Criteria) this;
}
public Criteria andEmailLike(String value) {
addCriterion("email like", value, "email");
return (Criteria) this;
}
public Criteria andEmailNotLike(String value) {
addCriterion("email not like", value, "email");
return (Criteria) this;
}
public Criteria andEmailIn(List<String> values) {
addCriterion("email in", values, "email");
return (Criteria) this;
}
public Criteria andEmailNotIn(List<String> values) {
addCriterion("email not in", values, "email");
return (Criteria) this;
}
public Criteria andEmailBetween(String value1, String value2) {
addCriterion("email between", value1, value2, "email");
return (Criteria) this;
}
public Criteria andEmailNotBetween(String value1, String value2) {
addCriterion("email not between", value1, value2, "email");
return (Criteria) this;
}
public Criteria andDidIsNull() {
addCriterion("did is null");
return (Criteria) this;
}
public Criteria andDidIsNotNull() {
addCriterion("did is not null");
return (Criteria) this;
}
public Criteria andDidEqualTo(Integer value) {
addCriterion("did =", value, "did");
return (Criteria) this;
}
public Criteria andDidNotEqualTo(Integer value) {
addCriterion("did <>", value, "did");
return (Criteria) this;
}
public Criteria andDidGreaterThan(Integer value) {
addCriterion("did >", value, "did");
return (Criteria) this;
}
public Criteria andDidGreaterThanOrEqualTo(Integer value) {
addCriterion("did >=", value, "did");
return (Criteria) this;
}
public Criteria andDidLessThan(Integer value) {
addCriterion("did <", value, "did");
return (Criteria) this;
}
public Criteria andDidLessThanOrEqualTo(Integer value) {
addCriterion("did <=", value, "did");
return (Criteria) this;
}
public Criteria andDidIn(List<Integer> values) {
addCriterion("did in", values, "did");
return (Criteria) this;
}
public Criteria andDidNotIn(List<Integer> values) {
addCriterion("did not in", values, "did");
return (Criteria) this;
}
public Criteria andDidBetween(Integer value1, Integer value2) {
addCriterion("did between", value1, value2, "did");
return (Criteria) this;
}
public Criteria andDidNotBetween(Integer value1, Integer value2) {
addCriterion("did not between", value1, value2, "did");
return (Criteria) this;
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table t_emp
*
* @mbggenerated do_not_delete_during_merge Wed Jan 04 16:17:13 CST 2023
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table t_emp
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}
Dept.java(自动生成)
package top.qaqaq.mybatis.pojo;
public class Dept {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column t_dept.did
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
private Integer did;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column t_dept.dept_name
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
private String deptName;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column t_dept.did
*
* @return the value of t_dept.did
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public Integer getDid() {
return did;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column t_dept.did
*
* @param did the value for t_dept.did
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setDid(Integer did) {
this.did = did;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column t_dept.dept_name
*
* @return the value of t_dept.dept_name
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public String getDeptName() {
return deptName;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column t_dept.dept_name
*
* @param deptName the value for t_dept.dept_name
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setDeptName(String deptName) {
this.deptName = deptName == null ? null : deptName.trim();
}
}
DeptExample.java(自动生成)
package top.qaqaq.mybatis.pojo;
import java.util.ArrayList;
import java.util.List;
public class DeptExample {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected String orderByClause;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected boolean distinct;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected List<Criteria> oredCriteria;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public DeptExample() {
oredCriteria = new ArrayList<Criteria>();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public String getOrderByClause() {
return orderByClause;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public boolean isDistinct() {
return distinct;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andDidIsNull() {
addCriterion("did is null");
return (Criteria) this;
}
public Criteria andDidIsNotNull() {
addCriterion("did is not null");
return (Criteria) this;
}
public Criteria andDidEqualTo(Integer value) {
addCriterion("did =", value, "did");
return (Criteria) this;
}
public Criteria andDidNotEqualTo(Integer value) {
addCriterion("did <>", value, "did");
return (Criteria) this;
}
public Criteria andDidGreaterThan(Integer value) {
addCriterion("did >", value, "did");
return (Criteria) this;
}
public Criteria andDidGreaterThanOrEqualTo(Integer value) {
addCriterion("did >=", value, "did");
return (Criteria) this;
}
public Criteria andDidLessThan(Integer value) {
addCriterion("did <", value, "did");
return (Criteria) this;
}
public Criteria andDidLessThanOrEqualTo(Integer value) {
addCriterion("did <=", value, "did");
return (Criteria) this;
}
public Criteria andDidIn(List<Integer> values) {
addCriterion("did in", values, "did");
return (Criteria) this;
}
public Criteria andDidNotIn(List<Integer> values) {
addCriterion("did not in", values, "did");
return (Criteria) this;
}
public Criteria andDidBetween(Integer value1, Integer value2) {
addCriterion("did between", value1, value2, "did");
return (Criteria) this;
}
public Criteria andDidNotBetween(Integer value1, Integer value2) {
addCriterion("did not between", value1, value2, "did");
return (Criteria) this;
}
public Criteria andDeptNameIsNull() {
addCriterion("dept_name is null");
return (Criteria) this;
}
public Criteria andDeptNameIsNotNull() {
addCriterion("dept_name is not null");
return (Criteria) this;
}
public Criteria andDeptNameEqualTo(String value) {
addCriterion("dept_name =", value, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameNotEqualTo(String value) {
addCriterion("dept_name <>", value, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameGreaterThan(String value) {
addCriterion("dept_name >", value, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameGreaterThanOrEqualTo(String value) {
addCriterion("dept_name >=", value, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameLessThan(String value) {
addCriterion("dept_name <", value, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameLessThanOrEqualTo(String value) {
addCriterion("dept_name <=", value, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameLike(String value) {
addCriterion("dept_name like", value, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameNotLike(String value) {
addCriterion("dept_name not like", value, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameIn(List<String> values) {
addCriterion("dept_name in", values, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameNotIn(List<String> values) {
addCriterion("dept_name not in", values, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameBetween(String value1, String value2) {
addCriterion("dept_name between", value1, value2, "deptName");
return (Criteria) this;
}
public Criteria andDeptNameNotBetween(String value1, String value2) {
addCriterion("dept_name not between", value1, value2, "deptName");
return (Criteria) this;
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table t_dept
*
* @mbggenerated do_not_delete_during_merge Wed Jan 04 16:17:13 CST 2023
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
/**
* This class was generated by MyBatis Generator.
* This class corresponds to the database table t_dept
*
* @mbggenerated Wed Jan 04 16:17:13 CST 2023
*/
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}
test
MBGTest .java
package top.qaqaq.mybatis.test;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;
import top.qaqaq.mybatis.mapper.EmpMapper;
import top.qaqaq.mybatis.pojo.Emp;
import top.qaqaq.mybatis.pojo.EmpExample;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
public class MBGTest {
@Test
public void testMBG() {
try {
InputStream is = Resources.getResourceAsStream("mybatis-config.xml");
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
SqlSession sqlSession = sqlSessionFactory.openSession(true);
EmpMapper mapper = sqlSession.getMapper(EmpMapper.class);
//查询所有数据
//List<Emp> list = mapper.selectByExample(null);
//ist.forEach(emp -> System.out.println(emp));
//System.out.println("********************************************************");
//根据条件查询
//EmpExample example = new EmpExample();
//example.createCriteria().andEmpNameEqualTo("张三").andAgeGreaterThanOrEqualTo(20);
//example.or().andDidIsNotNull();
//List<Emp> list = mapper.selectByExample(example);
//list.forEach(emp -> System.out.println(emp));
//根据主键直接修改
//mapper.updateByPrimaryKey(new Emp(1,"admin",22,null,"456@qq.com",3));
//根据主键选择性修改
mapper.updateByPrimaryKeySelective(new Emp(1,"admin",22,null,"456@qq.com",3));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}