<?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.powernode.bank.mappers.AccountMapper">
<resultMap id="BaseResultMap" type="com.powernode.bank.pojo.Account">
<id column="actno" jdbcType="VARCHAR" property="actno" />
<result column="balance" jdbcType="DOUBLE" property="balance" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
actno, balance
</sql>
<update id="update">
update t_act set balance = #{balance} where actnp = #{actno}
</update>
<select id="selectAll" resultType="Account">
select * from t_act
</select>
<select id="selectByExample" parameterType="com.powernode.bank.pojo.AccountExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_act
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByActno" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_act
where actno = #{actno,jdbcType=VARCHAR}
</select>
<delete id="deleteByActno" parameterType="java.lang.String">
delete from t_act
where actno = #{actno,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.powernode.bank.pojo.AccountExample">
delete from t_act
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.powernode.bank.pojo.Account">
insert into t_act (actno, balance)
values (#{actno,jdbcType=VARCHAR}, #{balance,jdbcType=DOUBLE})
</insert>
<insert id="insertSelective" parameterType="com.powernode.bank.pojo.Account">
insert into t_act
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="actno != null">
actno,
</if>
<if test="balance != null">
balance,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="actno != null">
#{actno,jdbcType=VARCHAR},
</if>
<if test="balance != null">
#{balance,jdbcType=DOUBLE},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.powernode.bank.pojo.AccountExample" resultType="java.lang.Long">
select count(*) from t_act
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_act
<set>
<if test="row.actno != null">
actno = #{row.actno,jdbcType=VARCHAR},
</if>
<if test="row.balance != null">
balance = #{row.balance,jdbcType=DOUBLE},
</if>
</set>
<if test="example != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_act
set actno = #{row.actno,jdbcType=VARCHAR},
balance = #{row.balance,jdbcType=DOUBLE}
<if test="example != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.powernode.bank.pojo.Account">
update t_act
<set>
<if test="balance != null">
balance = #{balance,jdbcType=DOUBLE},
</if>
</set>
where actno = #{actno,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.powernode.bank.pojo.Account">
update t_act
set balance = #{balance,jdbcType=DOUBLE}
where actno = #{actno,jdbcType=VARCHAR}
</update>
</mapper>
<?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.powernode.bank.mappers.AccountMapper">
<resultMap id="BaseResultMap" type="com.powernode.bank.pojo.Account">
<id column="actno" jdbcType="VARCHAR" property="actno" />
<result column="balance" jdbcType="DOUBLE" property="balance" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
actno, balance
</sql>
<update id="update">
update t_act set balance = #{balance} where actnp = #{actno}
</update>
<select id="selectAll" resultType="Account">
select * from t_act
</select>
<select id="selectByExample" parameterType="com.powernode.bank.pojo.AccountExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_act
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByActno" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_act
where actno = #{actno,jdbcType=VARCHAR}
</select>
<delete id="deleteByActno" parameterType="java.lang.String">
delete from t_act
where actno = #{actno,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.powernode.bank.pojo.AccountExample">
delete from t_act
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.powernode.bank.pojo.Account">
insert into t_act (actno, balance)
values (#{actno,jdbcType=VARCHAR}, #{balance,jdbcType=DOUBLE})
</insert>
<insert id="insertSelective" parameterType="com.powernode.bank.pojo.Account">
insert into t_act
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="actno != null">
actno,
</if>
<if test="balance != null">
balance,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="actno != null">
#{actno,jdbcType=VARCHAR},
</if>
<if test="balance != null">
#{balance,jdbcType=DOUBLE},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.powernode.bank.pojo.AccountExample" resultType="java.lang.Long">
select count(*) from t_act
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_act
<set>
<if test="row.actno != null">
actno = #{row.actno,jdbcType=VARCHAR},
</if>
<if test="row.balance != null">
balance = #{row.balance,jdbcType=DOUBLE},
</if>
</set>
<if test="example != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_act
set actno = #{row.actno,jdbcType=VARCHAR},
balance = #{row.balance,jdbcType=DOUBLE}
<if test="example != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.powernode.bank.pojo.Account">
update t_act
<set>
<if test="balance != null">
balance = #{balance,jdbcType=DOUBLE},
</if>
</set>
where actno = #{actno,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.powernode.bank.pojo.Account">
update t_act
set balance = #{balance,jdbcType=DOUBLE}
where actno = #{actno,jdbcType=VARCHAR}
</update>
</mapper>
package com.powernode.bank.mappers;
import com.powernode.bank.pojo.Account;
import com.powernode.bank.pojo.AccountExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface AccountMapper {
long countByExample(AccountExample example);
int deleteByExample(AccountExample example);
int deleteByActno(String actno);
int insert(Account row);
int update(Account act);
int insertSelective(Account row);
List<Account> selectAll();
List<Account> selectByExample(AccountExample example);
Account selectByActno(String actno);
int updateByExampleSelective(@Param("row") Account row, @Param("example") AccountExample example);
int updateByExample(@Param("row") Account row, @Param("example") AccountExample example);
int updateByPrimaryKeySelective(Account row);
int updateByPrimaryKey(Account row);
}
package com.powernode.bank.mappers;
import com.powernode.bank.pojo.Account;
import com.powernode.bank.pojo.AccountExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface AccountMapper {
long countByExample(AccountExample example);
int deleteByExample(AccountExample example);
int deleteByActno(String actno);
int insert(Account row);
int update(Account act);
int insertSelective(Account row);
List<Account> selectAll();
List<Account> selectByExample(AccountExample example);
Account selectByActno(String actno);
int updateByExampleSelective(@Param("row") Account row, @Param("example") AccountExample example);
int updateByExample(@Param("row") Account row, @Param("example") AccountExample example);
int updateByPrimaryKeySelective(Account row);
int updateByPrimaryKey(Account row);
}
<?xml version="1.0" encoding="UTF-8"?>
<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>com.powernode</groupId>
<artifactId>spring6-015-sm</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<repositories>
<!--Spring里程碑版本的仓库-->
<repository>
<id>repository.spring.milestone</id>
<name>Spring Milestone Repository</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<dependencies>
<!--spring context依赖-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.0-M2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>6.1.0-M2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.10</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<!--当你引入Spring Context后,表示将Spring的基础依赖引入了-->
<!--但想使用Spring的JDBC或其他的tx时,还需要再次添加依赖-->
<!--引入Log4j2的依赖-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>6.1.0-M2</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.19.0</version>
</dependency>
<!--JUNIT依赖-->
</dependencies>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- 配置mybatis逆向工程的插件,build表示构建逆向工程-->
<build>
<!-- plugins表示配置多个插件-->
<plugins>
<plugin>
<!-- 插件的坐标-->
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.4.2</version>
<!-- 允许覆盖,必须要有,防止生成的内容不是覆盖而是追加到源程序上导致错误-->
<configuration>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<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>com.powernode</groupId>
<artifactId>spring6-015-sm</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<repositories>
<!--Spring里程碑版本的仓库-->
<repository>
<id>repository.spring.milestone</id>
<name>Spring Milestone Repository</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<dependencies>
<!--spring context依赖-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.0-M2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>6.1.0-M2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.10</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<!--当你引入Spring Context后,表示将Spring的基础依赖引入了-->
<!--但想使用Spring的JDBC或其他的tx时,还需要再次添加依赖-->
<!--引入Log4j2的依赖-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.19.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>6.1.0-M2</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>2.19.0</version>
</dependency>
<!--JUNIT依赖-->
</dependencies>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- 配置mybatis逆向工程的插件,build表示构建逆向工程-->
<build>
<!-- plugins表示配置多个插件-->
<plugins>
<plugin>
<!-- 插件的坐标-->
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.4.2</version>
<!-- 允许覆盖,必须要有,防止生成的内容不是覆盖而是追加到源程序上导致错误-->
<configuration>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
package com.powernode.bank.pojo;
public class Account {
private String actno;
private Double balance;
public Account() {
}
@Override
public String toString() {
return "Account{" +
"actno='" + actno + '\'' +
", balance=" + balance +
'}';
}
public Account(String actno, Double balance) {
this.actno = actno;
this.balance = balance;
}
public String getActno() {
return actno;
}
public void setActno(String actno) {
this.actno = actno == null ? null : actno.trim();
}
public Double getBalance() {
return balance;
}
public void setBalance(Double balance) {
this.balance = balance;
}
}
package com.powernode.bank.pojo;
public class Account {
private String actno;
private Double balance;
public Account() {
}
@Override
public String toString() {
return "Account{" +
"actno='" + actno + '\'' +
", balance=" + balance +
'}';
}
public Account(String actno, Double balance) {
this.actno = actno;
this.balance = balance;
}
public String getActno() {
return actno;
}
public void setActno(String actno) {
this.actno = actno == null ? null : actno.trim();
}
public Double getBalance() {
return balance;
}
public void setBalance(Double balance) {
this.balance = balance;
}
}