看了很多帖子,网上生成中文注释的 还有写代码工具类 而且不管用 不通用 生成的dao接口方法还少 不是很完全
本教程简单通用 直接一键生成
1.ORACLE
准备工具
配置文件GeneratorConfig
<?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="D:\generator_tool\ojdbc14.jar" />
<context id="my" targetRuntime="MyBatis3">
<commentGenerator type="org.mybatis.generator.internal.CustomeCommentGenerator">
<property name="javaFileEncoding" value="UTF-8" />
<property name="suppressDate" value="false" />
<property name="suppressAllComments" value="false" />
</commentGenerator>
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@1xxxx:1521:orcl"
userId="xxx" password="xxxx" >
<property name="remarksReporting" value="true" />
</jdbcConnection>
<javaModelGenerator targetPackage="com.xql.microservicemy.model"
targetProject="D:/generator_tool/src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.xql.mapper"
targetProject="D:/generator_tool/src/main/resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<javaClientGenerator targetPackage="com.xql.microservicemy.dao"
targetProject="D:/generator_tool/src/main/java"
type="XMLMAPPER">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<table tableName="CM_PERSON" domainObjectName="Person"
enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>
</context>
</generatorConfiguration>
注意:修改吧jar包路径换成自己本地jar路径 和生成文件路径 可以改成自己项目路径
3 当前窗口打开本地cmd命令窗口
首先确定本地已安装配置java环境
然后输入:
java -jar mybatis-generator-core-1.0.1.jar -configfile generatorConfig.xml -overwrite
4.查看生成的代码
package com.xql.microservicemy.model;
import com.yiwupay.utils.annotation.FieldMeta;
/**
* 数据库表名为: CM_PERSON
*/
public class Person {
@FieldMeta(id=true,name="PERSON_SID",description="人SID")
private Long personSid;
@FieldMeta(name="NAME",description="姓名")
private String name;
@FieldMeta(name="ROMAN_NAME",description="罗马名")
private String romanName;
@FieldMeta(name="CERTIFICATE_NAME",description="原名")
private String certificateName;
@FieldMeta(name="BIRTHDAY",description="生日")
private Integer birthday;
@FieldMeta(name="SEX_ID",description="性别ID")
private String sexId;
@FieldMeta(name="COUNTRY_ID",description="国籍ID")
private String countryId;
@FieldMeta(name="ETHNIC_ID",description="民族ID")
private String ethnicId;
@FieldMeta(name="REGISTERED_DATETIME",description="注册时间")
private Long registeredDatetime;
@FieldMeta(name="REGISTERED_USER_NAME",description="注册用户")
private String registeredUserName;
@FieldMeta(name="UPDATED_DATETIME",description="更新时间")
private Long updatedDatetime;
@FieldMeta(name="UPDATED_USER_NAME",description="更新用户")
private String updatedUserName;
@FieldMeta(name="SOCIAL_RELATION_ID",description="社会关系ID")
private String socialRelationId;
/**
* get method
*
* @return CM_PERSON.PERSON_SID:人SID
*/
public Long getPersonSid() {
return personSid;
}
/**
* set method
*
* @param personSid 人SID
*/
public void setPersonSid(Long personSid) {
this.personSid = personSid;
}
/**
* get method
*
* @return CM_PERSON.NAME:姓名
*/
public String getName() {
return name;
}
/**
* set method
*
* @param name 姓名
*/
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
/**
* get method
*
* @return CM_PERSON.ROMAN_NAME:罗马名
*/
public String getRomanName() {
return romanName;
}
/**
* set method
*
* @param romanName 罗马名
*/
public void setRomanName(String romanName) {
this.romanName = romanName == null ? null : romanName.trim();
}
/**
* get method
*
* @return CM_PERSON.CERTIFICATE_NAME:原名
*/
public String getCertificateName() {
return certificateName;
}
/**
* set method
*
* @param certificateName 原名
*/
public void setCertificateName(String certificateName) {
this.certificateName = certificateName == null ? null : certificateName.trim();
}
/**
* get method
*
* @return CM_PERSON.BIRTHDAY:生日
*/
public Integer getBirthday() {
return birthday;
}
/**
* set method
*
* @param birthday 生日
*/
public void setBirthday(Integer birthday) {
this.birthday = birthday;
}
/**
* get method
*
* @return CM_PERSON.SEX_ID:性别ID
*/
public String getSexId() {
return sexId;
}
/**
* set method
*
* @param sexId 性别ID
*/
public void setSexId(String sexId) {
this.sexId = sexId == null ? null : sexId.trim();
}
/**
* get method
*
* @return CM_PERSON.COUNTRY_ID:国籍ID
*/
public String getCountryId() {
return countryId;
}
/**
* set method
*
* @param countryId 国籍ID
*/
public void setCountryId(String countryId) {
this.countryId = countryId == null ? null : countryId.trim();
}
/**
* get method
*
* @return CM_PERSON.ETHNIC_ID:民族ID
*/
public String getEthnicId() {
return ethnicId;
}
/**
* set method
*
* @param ethnicId 民族ID
*/
public void setEthnicId(String ethnicId) {
this.ethnicId = ethnicId == null ? null : ethnicId.trim();
}
/**
* get method
*
* @return CM_PERSON.REGISTERED_DATETIME:注册时间
*/
public Long getRegisteredDatetime() {
return registeredDatetime;
}
/**
* set method
*
* @param registeredDatetime 注册时间
*/
public void setRegisteredDatetime(Long registeredDatetime) {
this.registeredDatetime = registeredDatetime;
}
/**
* get method
*
* @return CM_PERSON.REGISTERED_USER_NAME:注册用户
*/
public String getRegisteredUserName() {
return registeredUserName;
}
/**
* set method
*
* @param registeredUserName 注册用户
*/
public void setRegisteredUserName(String registeredUserName) {
this.registeredUserName = registeredUserName == null ? null : registeredUserName.trim();
}
/**
* get method
*
* @return CM_PERSON.UPDATED_DATETIME:更新时间
*/
public Long getUpdatedDatetime() {
return updatedDatetime;
}
/**
* set method
*
* @param updatedDatetime 更新时间
*/
public void setUpdatedDatetime(Long updatedDatetime) {
this.updatedDatetime = updatedDatetime;
}
/**
* get method
*
* @return CM_PERSON.UPDATED_USER_NAME:更新用户
*/
public String getUpdatedUserName() {
return updatedUserName;
}
/**
* set method
*
* @param updatedUserName 更新用户
*/
public void setUpdatedUserName(String updatedUserName) {
this.updatedUserName = updatedUserName == null ? null : updatedUserName.trim();
}
/**
* get method
*
* @return CM_PERSON.SOCIAL_RELATION_ID:社会关系ID
*/
public String getSocialRelationId() {
return socialRelationId;
}
/**
* set method
*
* @param socialRelationId 社会关系ID
*/
public void setSocialRelationId(String socialRelationId) {
this.socialRelationId = socialRelationId == null ? null : socialRelationId.trim();
}
}
dao接口
package com.xql.microservicemy.dao;
import com.xql.microservicemy.model.Person;
import com.xql.microservicemy.model.PersonExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface PersonMapper {
/**
* 根据条件计数
*
* @param example
*/
int countByExample(PersonExample example);
/**
*
* @param example
*/
int deleteByExample(PersonExample example);
/**
* 根据主键删除数据库的记录
*
* @param personSid
*/
int deleteByPrimaryKey(Long personSid);
/**
* 插入数据库记录
*
* @param record
*/
int insert(Person record);
/**
* 插入数据库记录
*
* @param record
*/
int insertSelective(Person record);
/**
* 根据条件查询列表
*
* @param example
*/
List<Person> selectByExample(PersonExample example);
/**
* 根据主键获取一条数据库记录
*
* @param personSid
*/
Person selectByPrimaryKey(Long personSid);
/**
* 选择性更新数据库记录
*
* @param record
* @param example
*/
int updateByExampleSelective(@Param("record") Person record, @Param("example") PersonExample example);
/**
* 选择性更新数据库记录
*
* @param record
* @param example
*/
int updateByExample(@Param("record") Person record, @Param("example") PersonExample example);
/**
* 根据主键来更新部分数据库记录
*
* @param record
*/
int updateByPrimaryKeySelective(Person record);
/**
* 根据主键来更新数据库记录
*
* @param record
*/
int updateByPrimaryKey(Person record);
}
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.xql.microservicemy.dao.PersonMapper">
<resultMap id="BaseResultMap" type="com.xql.microservicemy.model.Person">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
<id column="PERSON_SID" jdbcType="DECIMAL" property="personSid" />
<result column="NAME" jdbcType="VARCHAR" property="name" />
<result column="ROMAN_NAME" jdbcType="VARCHAR" property="romanName" />
<result column="CERTIFICATE_NAME" jdbcType="VARCHAR" property="certificateName" />
<result column="BIRTHDAY" jdbcType="DECIMAL" property="birthday" />
<result column="SEX_ID" jdbcType="VARCHAR" property="sexId" />
<result column="COUNTRY_ID" jdbcType="VARCHAR" property="countryId" />
<result column="ETHNIC_ID" jdbcType="VARCHAR" property="ethnicId" />
<result column="REGISTERED_DATETIME" jdbcType="DECIMAL" property="registeredDatetime" />
<result column="REGISTERED_USER_NAME" jdbcType="VARCHAR" property="registeredUserName" />
<result column="UPDATED_DATETIME" jdbcType="DECIMAL" property="updatedDatetime" />
<result column="UPDATED_USER_NAME" jdbcType="VARCHAR" property="updatedUserName" />
<result column="SOCIAL_RELATION_ID" jdbcType="VARCHAR" property="socialRelationId" />
</resultMap>
<sql id="Example_Where_Clause">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
<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">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
<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">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
PERSON_SID, NAME, ROMAN_NAME, CERTIFICATE_NAME, BIRTHDAY, SEX_ID, COUNTRY_ID, ETHNIC_ID,
REGISTERED_DATETIME, REGISTERED_USER_NAME, UPDATED_DATETIME, UPDATED_USER_NAME, SOCIAL_RELATION_ID
</sql>
<select id="selectByExample" parameterType="com.xql.microservicemy.model.PersonExample" resultMap="BaseResultMap">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
select
<if test="distinct">
distinct
</if>
'true' as QUERYID,
<include refid="Base_Column_List" />
from CM_PERSON
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
select
<include refid="Base_Column_List" />
from CM_PERSON
where PERSON_SID = #{personSid,jdbcType=DECIMAL}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
delete from CM_PERSON
where PERSON_SID = #{personSid,jdbcType=DECIMAL}
</delete>
<delete id="deleteByExample" parameterType="com.xql.microservicemy.model.PersonExample">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
delete from CM_PERSON
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.xql.microservicemy.model.Person">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
insert into CM_PERSON (PERSON_SID, NAME, ROMAN_NAME,
CERTIFICATE_NAME, BIRTHDAY, SEX_ID,
COUNTRY_ID, ETHNIC_ID, REGISTERED_DATETIME,
REGISTERED_USER_NAME, UPDATED_DATETIME, UPDATED_USER_NAME,
SOCIAL_RELATION_ID)
values (#{personSid,jdbcType=DECIMAL}, #{name,jdbcType=VARCHAR}, #{romanName,jdbcType=VARCHAR},
#{certificateName,jdbcType=VARCHAR}, #{birthday,jdbcType=DECIMAL}, #{sexId,jdbcType=VARCHAR},
#{countryId,jdbcType=VARCHAR}, #{ethnicId,jdbcType=VARCHAR}, #{registeredDatetime,jdbcType=DECIMAL},
#{registeredUserName,jdbcType=VARCHAR}, #{updatedDatetime,jdbcType=DECIMAL}, #{updatedUserName,jdbcType=VARCHAR},
#{socialRelationId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.xql.microservicemy.model.Person">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
insert into CM_PERSON
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="personSid != null">
PERSON_SID,
</if>
<if test="name != null">
NAME,
</if>
<if test="romanName != null">
ROMAN_NAME,
</if>
<if test="certificateName != null">
CERTIFICATE_NAME,
</if>
<if test="birthday != null">
BIRTHDAY,
</if>
<if test="sexId != null">
SEX_ID,
</if>
<if test="countryId != null">
COUNTRY_ID,
</if>
<if test="ethnicId != null">
ETHNIC_ID,
</if>
<if test="registeredDatetime != null">
REGISTERED_DATETIME,
</if>
<if test="registeredUserName != null">
REGISTERED_USER_NAME,
</if>
<if test="updatedDatetime != null">
UPDATED_DATETIME,
</if>
<if test="updatedUserName != null">
UPDATED_USER_NAME,
</if>
<if test="socialRelationId != null">
SOCIAL_RELATION_ID,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="personSid != null">
#{personSid,jdbcType=DECIMAL},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="romanName != null">
#{romanName,jdbcType=VARCHAR},
</if>
<if test="certificateName != null">
#{certificateName,jdbcType=VARCHAR},
</if>
<if test="birthday != null">
#{birthday,jdbcType=DECIMAL},
</if>
<if test="sexId != null">
#{sexId,jdbcType=VARCHAR},
</if>
<if test="countryId != null">
#{countryId,jdbcType=VARCHAR},
</if>
<if test="ethnicId != null">
#{ethnicId,jdbcType=VARCHAR},
</if>
<if test="registeredDatetime != null">
#{registeredDatetime,jdbcType=DECIMAL},
</if>
<if test="registeredUserName != null">
#{registeredUserName,jdbcType=VARCHAR},
</if>
<if test="updatedDatetime != null">
#{updatedDatetime,jdbcType=DECIMAL},
</if>
<if test="updatedUserName != null">
#{updatedUserName,jdbcType=VARCHAR},
</if>
<if test="socialRelationId != null">
#{socialRelationId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.xql.microservicemy.model.PersonExample" resultType="java.lang.Integer">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
select count(*) from CM_PERSON
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
update CM_PERSON
<set>
<if test="record.personSid != null">
PERSON_SID = #{record.personSid,jdbcType=DECIMAL},
</if>
<if test="record.name != null">
NAME = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.romanName != null">
ROMAN_NAME = #{record.romanName,jdbcType=VARCHAR},
</if>
<if test="record.certificateName != null">
CERTIFICATE_NAME = #{record.certificateName,jdbcType=VARCHAR},
</if>
<if test="record.birthday != null">
BIRTHDAY = #{record.birthday,jdbcType=DECIMAL},
</if>
<if test="record.sexId != null">
SEX_ID = #{record.sexId,jdbcType=VARCHAR},
</if>
<if test="record.countryId != null">
COUNTRY_ID = #{record.countryId,jdbcType=VARCHAR},
</if>
<if test="record.ethnicId != null">
ETHNIC_ID = #{record.ethnicId,jdbcType=VARCHAR},
</if>
<if test="record.registeredDatetime != null">
REGISTERED_DATETIME = #{record.registeredDatetime,jdbcType=DECIMAL},
</if>
<if test="record.registeredUserName != null">
REGISTERED_USER_NAME = #{record.registeredUserName,jdbcType=VARCHAR},
</if>
<if test="record.updatedDatetime != null">
UPDATED_DATETIME = #{record.updatedDatetime,jdbcType=DECIMAL},
</if>
<if test="record.updatedUserName != null">
UPDATED_USER_NAME = #{record.updatedUserName,jdbcType=VARCHAR},
</if>
<if test="record.socialRelationId != null">
SOCIAL_RELATION_ID = #{record.socialRelationId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
update CM_PERSON
set PERSON_SID = #{record.personSid,jdbcType=DECIMAL},
NAME = #{record.name,jdbcType=VARCHAR},
ROMAN_NAME = #{record.romanName,jdbcType=VARCHAR},
CERTIFICATE_NAME = #{record.certificateName,jdbcType=VARCHAR},
BIRTHDAY = #{record.birthday,jdbcType=DECIMAL},
SEX_ID = #{record.sexId,jdbcType=VARCHAR},
COUNTRY_ID = #{record.countryId,jdbcType=VARCHAR},
ETHNIC_ID = #{record.ethnicId,jdbcType=VARCHAR},
REGISTERED_DATETIME = #{record.registeredDatetime,jdbcType=DECIMAL},
REGISTERED_USER_NAME = #{record.registeredUserName,jdbcType=VARCHAR},
UPDATED_DATETIME = #{record.updatedDatetime,jdbcType=DECIMAL},
UPDATED_USER_NAME = #{record.updatedUserName,jdbcType=VARCHAR},
SOCIAL_RELATION_ID = #{record.socialRelationId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.xql.microservicemy.model.Person">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
update CM_PERSON
<set>
<if test="name != null">
NAME = #{name,jdbcType=VARCHAR},
</if>
<if test="romanName != null">
ROMAN_NAME = #{romanName,jdbcType=VARCHAR},
</if>
<if test="certificateName != null">
CERTIFICATE_NAME = #{certificateName,jdbcType=VARCHAR},
</if>
<if test="birthday != null">
BIRTHDAY = #{birthday,jdbcType=DECIMAL},
</if>
<if test="sexId != null">
SEX_ID = #{sexId,jdbcType=VARCHAR},
</if>
<if test="countryId != null">
COUNTRY_ID = #{countryId,jdbcType=VARCHAR},
</if>
<if test="ethnicId != null">
ETHNIC_ID = #{ethnicId,jdbcType=VARCHAR},
</if>
<if test="registeredDatetime != null">
REGISTERED_DATETIME = #{registeredDatetime,jdbcType=DECIMAL},
</if>
<if test="registeredUserName != null">
REGISTERED_USER_NAME = #{registeredUserName,jdbcType=VARCHAR},
</if>
<if test="updatedDatetime != null">
UPDATED_DATETIME = #{updatedDatetime,jdbcType=DECIMAL},
</if>
<if test="updatedUserName != null">
UPDATED_USER_NAME = #{updatedUserName,jdbcType=VARCHAR},
</if>
<if test="socialRelationId != null">
SOCIAL_RELATION_ID = #{socialRelationId,jdbcType=VARCHAR},
</if>
</set>
where PERSON_SID = #{personSid,jdbcType=DECIMAL}
</update>
<update id="updateByPrimaryKey" parameterType="com.xql.microservicemy.model.Person">
<!--
@MBG Generated
This element is automatically generated by MyBatis Generator,Do not modify ! Generated on Tue Aug 18 15:23:23 CST 2020.
-->
update CM_PERSON
set NAME = #{name,jdbcType=VARCHAR},
ROMAN_NAME = #{romanName,jdbcType=VARCHAR},
CERTIFICATE_NAME = #{certificateName,jdbcType=VARCHAR},
BIRTHDAY = #{birthday,jdbcType=DECIMAL},
SEX_ID = #{sexId,jdbcType=VARCHAR},
COUNTRY_ID = #{countryId,jdbcType=VARCHAR},
ETHNIC_ID = #{ethnicId,jdbcType=VARCHAR},
REGISTERED_DATETIME = #{registeredDatetime,jdbcType=DECIMAL},
REGISTERED_USER_NAME = #{registeredUserName,jdbcType=VARCHAR},
UPDATED_DATETIME = #{updatedDatetime,jdbcType=DECIMAL},
UPDATED_USER_NAME = #{updatedUserName,jdbcType=VARCHAR},
SOCIAL_RELATION_ID = #{socialRelationId,jdbcType=VARCHAR}
where PERSON_SID = #{personSid,jdbcType=DECIMAL}
</update>
</mapper>
相关pom依赖:
mybtais的
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.3.0</version>
</dependency>
第二个是手动写的jar包 通用 需要可以滴滴我
<dependency>
<groupId>com.xql.utils</groupId>
<artifactId>utils</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
2 mysql
操作和oracle一致
1.修改本地generatorConfigLocal.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="D:\generator_tool\mysql\mysql-connector-java-5.0.4.jar" />
<context id="my" targetRuntime="MyBatis3">
<commentGenerator type="org.mybatis.generator.internal.CustomeCommentGenerator">
<property name="javaFileEncoding" value="UTF-8" />
<property name="suppressDate" value="false" />
<property name="suppressAllComments" value="false" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://182.92.129.11:3306/cloudDB01"
userId="root" password="xql123" >
<property name="remarksReporting" value="true" />
</jdbcConnection>
<javaModelGenerator targetPackage="com.xql.consumerdept8086.model"
targetProject="D:/Microservice/consumer-dept-8086/src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.xql.consumerdept8086.mapper"
targetProject="D:/Microservice/consumer-dept-8086/src/main/resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>
<javaClientGenerator targetPackage="com.xql.consumerdept8086.dao"
targetProject="D:/Microservice/consumer-dept-8086/src/main/java"
type="XMLMAPPER">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<table tableName="dept" domainObjectName="DEPT"
enableCountByExample="true" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>
</context>
</generatorConfiguration>
当前cmd命令窗口运行命令
java -jar mybatis-generator-core-1.0.1.jar -configfile generatorConfigLocal.xml -overwrite