MyBatis是一种轻量级的ORM框架,相对于Hibernate来说比较简单易用,对于较小的系统或者对于SQL语句有独特爱好的朋友可以使用MyBatis进行开发。网上大多是直接照抄MyBatis官网提供的docs例子进行粘贴,具体能不能用还不得而知。下面以一个例子来介绍MyBatis的基本使用。
一、建立数据库表
创建用户表:
- DROP TABLE IF EXISTS user;
- CREATE TABLE user (
- username varchar(50) NOT NULL,
- password varchar(50) DEFAULT NULL,
- address varchar(50) DEFAULT NULL,
- age varchar(5) DEFAULT NULL,
- sex varchar(2) DEFAULT NULL,
- PRIMARY KEY (username)
- )
二、建立对应的DTO对象
- public class UserDto implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
- private String username;
- private String password;
- private String address;
- private String age;
- private String sex;
- public UserDto() {
- }
- public UserDto(String username, String password, String address, String age, String sex) {
- this.username = username;
- this.password = password;
- this.address = address;
- this.age = age;
- this.sex = sex;
- }
- public String getUsername() {
- return this.username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return this.password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getAddress() {
- return this.address;
- }
- public void setAddress(String address) {
- this.address = address;
- }
- public String getAge() {
- return this.age;
- }
- public void setAge(String age) {
- this.age = age;
- }
- public String getSex() {
- return this.sex;
- }
- public void setSex(String sex) {
- this.sex = sex;
- }
- }
三、建立MyBatis系统配置文件[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>
- <environments default="development">
- <environment id="development">
- <transactionManager type="JDBC" />
- <dataSource type="POOLED">
- <property name="driver" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://127.0.0.1:3306/test" />
- <property name="username" value="test" />
- <property name="password" value="test" />
- </dataSource>
- </environment>
- </environments>
- <mappers>
- <mapper resource="UserMapper.xml" />
- </mappers>
- </configuration>
四、建立user表的映射文件(UserMapper.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.mapper.UserMapper">
- <select id="selectUser" parameterType="String" resultType="com.dto.UserDto">
- select * from user where username = #{username}
- </select>
- </mapper>
五、建立映射接口类(如果sql语句写在映射的配置XML文件,这一步可以不用)
- package com.mapper;
- import org.apache.ibatis.annotations.Select;
- import com.dto.UserDto;
- public interface UserMapper {
- @Select("select * from user where username = #{username}")
- public UserDto seleteUser(String username);
- }
六、建立测试类
- package com.test;
- import java.io.InputStream;
- import org.apache.ibatis.binding.MapperRegistry;
- import org.apache.ibatis.io.Resources;
- import org.apache.ibatis.session.Configuration;
- import org.apache.ibatis.session.SqlSession;
- import org.apache.ibatis.session.SqlSessionFactory;
- import org.apache.ibatis.session.SqlSessionFactoryBuilder;
- import org.junit.Before;
- import org.junit.Test;
- import com.dto.UserDto;
- import com.mapper.UserMapper;
- public class UserTest {
- SqlSessionFactory sqlSessionFactory = null;
- @Before
- public void setUp() throws Exception {
- String resource = "mybatis-config.xml";
- InputStream inputStream = Resources.getResourceAsStream(resource);
- sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
- Configuration configuration = sqlSessionFactory.getConfiguration();
- MapperRegistry mapperRegistry = configuration.getMapperRegistry();
- System.out.println(mapperRegistry.getMappers());
- }
- @Test
- public void seleteXMLTest(){
- SqlSession session = sqlSessionFactory.openSession();
- try {
- UserDto userDto = (UserDto) session.selectOne("com.mapper.UserMapper.selectUser", "xyz");
- System.out.println(userDto.getUsername());
- System.out.println(userDto.getPassword());
- System.out.println(userDto.getAddress());
- System.out.println(userDto.getAge());
- System.out.println(userDto.getSex());
- } finally {
- session.close();
- }
- }
- @Test
- public void seleteAnnotaionTest(){
- SqlSession session = sqlSessionFactory.openSession();
- try {
- UserMapper userMapper = session.getMapper(UserMapper.class);
- UserDto userDto = userMapper.seleteUser("xyz");
- System.out.println(userDto.getUsername());
- System.out.println(userDto.getPassword());
- System.out.println(userDto.getAddress());
- System.out.println(userDto.getAge());
- System.out.println(userDto.getSex());
- } finally {
- session.close();
- }
- }
- }
MyBatis3.2.2的源码下载地址:http://download.csdn.net/detail/wyc_cs/5272910
使用MyBatis进行数据库增删改查的操作是很简单的,主要在配置文件中写好相应的SQL语句,然后在程序中进行调用即可。具体代码如下:
一、映射配置文件
- <?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.mapper.UserMapper">
- <select id="selectUser" parameterType="String" resultType="com.dto.UserDto">
- select * from user where username = #{username}
- </select>
- <select id="selectAllUser" resultType="com.dto.UserDto">
- select * from user
- </select>
- <insert id="insertUser" parameterType="com.dto.UserDto">
- insert into user(username,password,address,age,sex)
- values (#{username},#{password},#{address},#{age},#{sex})
- </insert>
- <update id="updateUser" parameterType="com.dto.UserDto">
- update user set password=#{password},address=#{address},age=#{age},sex=#{sex}
- where username=#{username}
- </update>
- <delete id="deleteUser" parameterType="String">
- delete from user where username=#{username}
- </delete>
- <delete id="deleteAllUser">
- delete from user
- </delete>
- </mapper>
二、测试类
- package com.test;
- import java.io.InputStream;
- import java.util.List;
- import org.apache.ibatis.binding.MapperRegistry;
- import org.apache.ibatis.io.Resources;
- import org.apache.ibatis.session.Configuration;
- import org.apache.ibatis.session.SqlSession;
- import org.apache.ibatis.session.SqlSessionFactory;
- import org.apache.ibatis.session.SqlSessionFactoryBuilder;
- import org.junit.Before;
- import org.junit.Test;
- import com.dto.UserDto;
- import com.mapper.UserMapper;
- public class UserTest{
- SqlSessionFactory sqlSessionFactory = null;
- @Before
- public void setUp() throws Exception {
- String resource = "mybatis-config.xml";
- InputStream inputStream = Resources.getResourceAsStream(resource);
- sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
- }
- @Test
- public void seleteXMLTest() {
- SqlSession session = sqlSessionFactory.openSession();
- try {
- UserDto userDto = (UserDto) session.selectOne("com.mapper.UserMapper.selectUser", "test");
- System.out.println(userDto.getUsername()+"\t"+userDto.getPassword()+"\t"+userDto.getAddress()+"\t"+userDto.getAge()+"\t"+userDto.getSex());
- } finally {
- session.close();
- }
- }
- @Test
- public void seleteAllXMLTest() {
- SqlSession session = sqlSessionFactory.openSession();
- try {
- List<UserDto> list = session.selectList("com.mapper.UserMapper.selectAllUser");
- for(UserDto userDto : list){
- System.out.println(userDto.getUsername()+"\t"+userDto.getPassword()+"\t"+userDto.getAddress()+"\t"+userDto.getAge()+"\t"+userDto.getSex());
- }
- } finally {
- session.close();
- }
- }
- @Test
- public void seleteAnnotaionTest() {
- SqlSession session = sqlSessionFactory.openSession();
- try {
- UserMapper userMapper = session.getMapper(UserMapper.class);
- UserDto userDto = userMapper.seleteUser("test");
- System.out.println(userDto.getUsername()+"\t"+userDto.getPassword()+"\t"+userDto.getAddress()+"\t"+userDto.getAge()+"\t"+userDto.getSex());
- } finally {
- session.close();
- }
- }
- @Test
- public void insertXMLTest() {
- SqlSession session = sqlSessionFactory.openSession();
- try {
- UserDto userDto = new UserDto();
- userDto.setUsername("test");
- userDto.setPassword("test");
- userDto.setAddress("测试地址......");
- userDto.setAge("30");
- userDto.setSex("男");
- int res = session.insert("com.mapper.UserMapper.insertUser", userDto);
- session.commit();
- System.out.println("res = " + res);
- } finally {
- session.close();
- }
- }
- @Test
- public void updateXMLTest() {
- SqlSession session = sqlSessionFactory.openSession();
- try {
- UserDto userDto = new UserDto();
- userDto.setUsername("test");
- userDto.setPassword("111111");
- userDto.setAddress("地址");
- userDto.setAge("33");
- userDto.setSex("女");
- int res = session.update("com.mapper.UserMapper.updateUser", userDto);
- session.commit();
- System.out.println("res = " + res);
- } finally {
- session.close();
- }
- }
- @Test
- public void deleteXMLTest() {
- SqlSession session = sqlSessionFactory.openSession();
- try {
- int res = session.delete("com.mapper.UserMapper.deleteUser", "test");
- session.commit();
- System.out.println("res = " + res);
- } finally {
- session.close();
- }
- }
- @Test
- public void deleteAllXMLTest() {
- SqlSession session = sqlSessionFactory.openSession();
- try {
- int res = session.delete("com.mapper.UserMapper.deleteAllUser");
- session.commit();
- System.out.println("res = " + res);
- } finally {
- session.close();
- }
- }
- }
注意:在更新操作完成之后需要调用session.commit()方法,不然数据不会更新到数据库中。
在MyBatis的映射配置文件中写sql语句有时候很方便,但是对于有大量字段的表结构却不太简单,幸好MyBatis提供的有SqlBuilder工具类,可以生成相应的SQL语句,如下例程:
- package com.utils;
- import org.apache.ibatis.jdbc.SqlBuilder;
- public class MyBatisUtils extends SqlBuilder {
- public String selectUserSql() {
- BEGIN();
- SELECT("*");
- FROM("UserDto");
- return SQL();
- }
- public String deleteUserSql() {
- BEGIN();
- DELETE_FROM("UserDto");
- WHERE("username = #{username}");
- return SQL();
- }
- public String insertUserSql() {
- BEGIN();
- INSERT_INTO("UserDto");
- VALUES("username", "#{username}");
- VALUES("password", "#{password}");
- VALUES("address", "#{address}");
- VALUES("age", "#{age}");
- VALUES("sex", "#{sex}");
- return SQL();
- }
- public String updateUserSql() {
- BEGIN();
- UPDATE("UserDto");
- SET("password = #{password}");
- WHERE("username = #{username}");
- return SQL();
- }
- public static void main(String[] args) {
- MyBatisUtils myBatisUtils = new MyBatisUtils();
- System.out.println("查询 = " + myBatisUtils.selectUserSql());
- System.out.println("删除 = " + myBatisUtils.deleteUserSql());
- System.out.println("插入 = " + myBatisUtils.insertUserSql());
- System.out.println("更新 = " + myBatisUtils.updateUserSql());
- }
- }
使用MyBatis_Generator生成Dto、Dao、Mapping
由于MyBatis属于一种半自动的ORM框架,所以主要的工作将是书写Mapping映射文件,但是由于手写映射文件很容易出错,所以查资料发现有现成的工具可以自动生成底层模型类、Dao接口类甚至Mapping映射文件。
一、建立表结构
CREATE TABLE `user` (
`id` varchar(50) NOT NULL,
`username` varchar(18) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`password` varchar(18) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`name` varchar(18) DEFAULT NULL,
`sex` varchar(2) DEFAULT NULL,
`birthday` varchar(50) DEFAULT NULL,
`address` varchar(500) DEFAULT NULL,
`tel` varchar(18) DEFAULT NULL,
`qq` varchar(18) DEFAULT NULL,
`image` varchar(50) DEFAULT NULL,
`sfjh` varchar(1) DEFAULT NULL,
`sfzx` varchar(1) DEFAULT NULL,
`sfhf` varchar(1) DEFAULT NULL,
`sfpl` varchar(1) DEFAULT NULL,
`sffx` varchar(1) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf-8;
二、下载mybatis-generator-core
进入:http://code.google.com/p/mybatis/
选择Downloads,再选择MyBatis Generator Tool下载即可。
三、生成配置文件
新建一个空的XML配置文件,名称可以随便取,这里以generatorConfig.xml为名。最好将这个文件放在下载后的lib目录中,如图:
其中mysql的驱动可以随便放在非中文路径的地方,这里为了方便就放在lib目录下。
自动生成最重要的就是配置文件的书写,现在就开始介绍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>
- <!-- 数据库驱动-->
- <classPathEntry location="mysql-connector-java-5.0.6-bin.jar"/>
- <context id="DB2Tables" targetRuntime="MyBatis3">
- <commentGenerator>
- <property name="suppressDate" value="true"/>
- <!-- 是否去除自动生成的注释 true:是 : false:否 -->
- <property name="suppressAllComments" value="true"/>
- </commentGenerator>
- <!--数据库链接URL,用户名、密码 -->
- <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/test" userId="test" password="test">
- </jdbcConnection>
- <javaTypeResolver>
- <property name="forceBigDecimals" value="false"/>
- </javaTypeResolver>
- <!-- 生成模型的包名和位置-->
- <javaModelGenerator targetPackage="test.model" targetProject="src">
- <property name="enableSubPackages" value="true"/>
- <property name="trimStrings" value="true"/>
- </javaModelGenerator>
- <!-- 生成映射文件的包名和位置-->
- <sqlMapGenerator targetPackage="test.mapping" targetProject="src">
- <property name="enableSubPackages" value="true"/>
- </sqlMapGenerator>
- <!-- 生成DAO的包名和位置-->
- <javaClientGenerator type="XMLMAPPER" targetPackage="test.dao" targetProject="src">
- <property name="enableSubPackages" value="true"/>
- </javaClientGenerator>
- <!-- 要生成哪些表-->
- <table tableName="about" domainObjectName="AboutDto" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
- <table tableName="user" domainObjectName="UserDto" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
- <table tableName="syslogs" domainObjectName="SyslogsDto" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
- </context>
- </generatorConfiguration>
1、其中需要注意的有数据库驱动、数据库URL、用户名、密码、生成模型的包名和位置、生成映射文件的包名和位置、生成DAO的包名和位置以及最后需要生成的表名和对应的类名。
四、运行
需要通过CMD命令行方式来运行,首先可以先准备一个运行的脚本,这里使用的脚本是:java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite
需要注意的是:mybatis-generator-core-1.3.2.jar为下载的对应版本的jar,generatorConfig.xml 为配置文件名,如果不为这个可以在这里进行修改。
启动cmd进入到“F:\soft\mybatis-generator-core-1.3.2\lib”这个目录下,如图:
生成成功后进到src目录下,可以看到已经生成了对应的model、dao、mapping,如图:
下面可以看看生成后的UserMapper.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="test.dao.UserDtoMapper" >
- <resultMap id="BaseResultMap" type="test.model.UserDto" >
- <id column="id" property="id" jdbcType="VARCHAR" />
- <result column="username" property="username" jdbcType="VARCHAR" />
- <result column="password" property="password" jdbcType="VARCHAR" />
- <result column="email" property="email" jdbcType="VARCHAR" />
- <result column="name" property="name" jdbcType="VARCHAR" />
- <result column="sex" property="sex" jdbcType="VARCHAR" />
- <result column="birthday" property="birthday" jdbcType="VARCHAR" />
- <result column="address" property="address" jdbcType="VARCHAR" />
- <result column="tel" property="tel" jdbcType="VARCHAR" />
- <result column="qq" property="qq" jdbcType="VARCHAR" />
- <result column="image" property="image" jdbcType="VARCHAR" />
- <result column="sfjh" property="sfjh" jdbcType="VARCHAR" />
- <result column="sfzx" property="sfzx" jdbcType="VARCHAR" />
- <result column="sfhf" property="sfhf" jdbcType="VARCHAR" />
- <result column="sfpl" property="sfpl" jdbcType="VARCHAR" />
- <result column="sffx" property="sffx" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="Base_Column_List" >
- id, username, password, email, name, sex, birthday, address, tel, qq, image, sfjh,
- sfzx, sfhf, sfpl, sffx
- </sql>
- <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
- select
- <include refid="Base_Column_List" />
- from user
- where id = #{id,jdbcType=VARCHAR}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
- delete from user
- where id = #{id,jdbcType=VARCHAR}
- </delete>
- <insert id="insert" parameterType="test.model.UserDto" >
- insert into user (id, username, password,
- email, name, sex, birthday,
- address, tel, qq, image,
- sfjh, sfzx, sfhf, sfpl,
- sffx)
- values (#{id,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
- #{email,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{birthday,jdbcType=VARCHAR},
- #{address,jdbcType=VARCHAR}, #{tel,jdbcType=VARCHAR}, #{qq,jdbcType=VARCHAR}, #{image,jdbcType=VARCHAR},
- #{sfjh,jdbcType=VARCHAR}, #{sfzx,jdbcType=VARCHAR}, #{sfhf,jdbcType=VARCHAR}, #{sfpl,jdbcType=VARCHAR},
- #{sffx,jdbcType=VARCHAR})
- </insert>
- <insert id="insertSelective" parameterType="test.model.UserDto" >
- insert into user
- <trim prefix="(" suffix=")" suffixOverrides="," >
- <if test="id != null" >
- id,
- </if>
- <if test="username != null" >
- username,
- </if>
- <if test="password != null" >
- password,
- </if>
- <if test="email != null" >
- email,
- </if>
- <if test="name != null" >
- name,
- </if>
- <if test="sex != null" >
- sex,
- </if>
- <if test="birthday != null" >
- birthday,
- </if>
- <if test="address != null" >
- address,
- </if>
- <if test="tel != null" >
- tel,
- </if>
- <if test="qq != null" >
- qq,
- </if>
- <if test="image != null" >
- image,
- </if>
- <if test="sfjh != null" >
- sfjh,
- </if>
- <if test="sfzx != null" >
- sfzx,
- </if>
- <if test="sfhf != null" >
- sfhf,
- </if>
- <if test="sfpl != null" >
- sfpl,
- </if>
- <if test="sffx != null" >
- sffx,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides="," >
- <if test="id != null" >
- #{id,jdbcType=VARCHAR},
- </if>
- <if test="username != null" >
- #{username,jdbcType=VARCHAR},
- </if>
- <if test="password != null" >
- #{password,jdbcType=VARCHAR},
- </if>
- <if test="email != null" >
- #{email,jdbcType=VARCHAR},
- </if>
- <if test="name != null" >
- #{name,jdbcType=VARCHAR},
- </if>
- <if test="sex != null" >
- #{sex,jdbcType=VARCHAR},
- </if>
- <if test="birthday != null" >
- #{birthday,jdbcType=VARCHAR},
- </if>
- <if test="address != null" >
- #{address,jdbcType=VARCHAR},
- </if>
- <if test="tel != null" >
- #{tel,jdbcType=VARCHAR},
- </if>
- <if test="qq != null" >
- #{qq,jdbcType=VARCHAR},
- </if>
- <if test="image != null" >
- #{image,jdbcType=VARCHAR},
- </if>
- <if test="sfjh != null" >
- #{sfjh,jdbcType=VARCHAR},
- </if>
- <if test="sfzx != null" >
- #{sfzx,jdbcType=VARCHAR},
- </if>
- <if test="sfhf != null" >
- #{sfhf,jdbcType=VARCHAR},
- </if>
- <if test="sfpl != null" >
- #{sfpl,jdbcType=VARCHAR},
- </if>
- <if test="sffx != null" >
- #{sffx,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective" parameterType="test.model.UserDto" >
- update user
- <set >
- <if test="username != null" >
- username = #{username,jdbcType=VARCHAR},
- </if>
- <if test="password != null" >
- password = #{password,jdbcType=VARCHAR},
- </if>
- <if test="email != null" >
- email = #{email,jdbcType=VARCHAR},
- </if>
- <if test="name != null" >
- name = #{name,jdbcType=VARCHAR},
- </if>
- <if test="sex != null" >
- sex = #{sex,jdbcType=VARCHAR},
- </if>
- <if test="birthday != null" >
- birthday = #{birthday,jdbcType=VARCHAR},
- </if>
- <if test="address != null" >
- address = #{address,jdbcType=VARCHAR},
- </if>
- <if test="tel != null" >
- tel = #{tel,jdbcType=VARCHAR},
- </if>
- <if test="qq != null" >
- qq = #{qq,jdbcType=VARCHAR},
- </if>
- <if test="image != null" >
- image = #{image,jdbcType=VARCHAR},
- </if>
- <if test="sfjh != null" >
- sfjh = #{sfjh,jdbcType=VARCHAR},
- </if>
- <if test="sfzx != null" >
- sfzx = #{sfzx,jdbcType=VARCHAR},
- </if>
- <if test="sfhf != null" >
- sfhf = #{sfhf,jdbcType=VARCHAR},
- </if>
- <if test="sfpl != null" >
- sfpl = #{sfpl,jdbcType=VARCHAR},
- </if>
- <if test="sffx != null" >
- sffx = #{sffx,jdbcType=VARCHAR},
- </if>
- </set>
- where id = #{id,jdbcType=VARCHAR}
- </update>
- <update id="updateByPrimaryKey" parameterType="test.model.UserDto" >
- update user
- set username = #{username,jdbcType=VARCHAR},
- password = #{password,jdbcType=VARCHAR},
- email = #{email,jdbcType=VARCHAR},
- name = #{name,jdbcType=VARCHAR},
- sex = #{sex,jdbcType=VARCHAR},
- birthday = #{birthday,jdbcType=VARCHAR},
- address = #{address,jdbcType=VARCHAR},
- tel = #{tel,jdbcType=VARCHAR},
- qq = #{qq,jdbcType=VARCHAR},
- image = #{image,jdbcType=VARCHAR},
- sfjh = #{sfjh,jdbcType=VARCHAR},
- sfzx = #{sfzx,jdbcType=VARCHAR},
- sfhf = #{sfhf,jdbcType=VARCHAR},
- sfpl = #{sfpl,jdbcType=VARCHAR},
- sffx = #{sffx,jdbcType=VARCHAR}
- where id = #{id,jdbcType=VARCHAR}
- </update>
- </mapper>
接下来就可以将这三个目录拷贝到对应项目的目录中,如果需要新增自己的方法可以修改dao类。