ibator改进,生成中文注释

转自:http://lj-zhu.iteye.com/blog/732325

 

 

修改ibator1.2.2(http://svn.apache.org/repos/asf/ibatis/java/ibator)

1) 修改org.apache.ibatis.ibator.api.Ibator类,

方法private void writeFile(File file, String content) throws IOException

修改编码如下:

Java代码 复制代码  收藏代码
  1. private void writeFile(File file, String content) throws IOException {   
  2.        java.io.OutputStreamWriter fos = new java.io.OutputStreamWriter(new java.io.FileOutputStream(file), "UTF-8");   
  3.         fos.write(content);   
  4.         fos.flush();   
  5.         fos.close();   
  6.     }  
private void writeFile(File file, String content) throws IOException {
       java.io.OutputStreamWriter fos = new java.io.OutputStreamWriter(new java.io.FileOutputStream(file), "UTF-8");
        fos.write(content);
        fos.flush();
        fos.close();
    }

 

2)修改org.apache.ibatis.ibator.internal.DefaultCommentGenerator类中的addFieldComment,addClassComment,addGetterComment,addSetterComment,addGeneralMethodComment,addComment方法,修改成你想要的格式。

修改如下方法:

Java代码 复制代码  收藏代码
  1. public void addClassComment(InnerClass innerClass,   
  2.             IntrospectedTable introspectedTable) {   
  3.         addClassComment(innerClass, introspectedTable.getFullyQualifiedTable(), false);   
  4.     }   
  5.   
  6.     public void addEnumComment(InnerEnum innerEnum,   
  7.             IntrospectedTable introspectedTable) {   
  8.         addEnumComment(innerEnum, introspectedTable.getFullyQualifiedTable());   
  9.     }   
  10.   
  11.     public void addFieldComment(Field field,   
  12.             IntrospectedTable introspectedTable,   
  13.             IntrospectedColumn introspectedColumn) {   
  14.         addFieldComment(field, introspectedTable.getFullyQualifiedTable(),   
  15.                 introspectedColumn.getRemarks());   
  16.     }   
  17.   
  18.     public void addFieldComment(Field field, IntrospectedTable introspectedTable) {   
  19.         addFieldComment(field, introspectedTable.getFullyQualifiedTable());   
  20.     }   
  21.   
  22.     public void addGeneralMethodComment(Method method,   
  23.             IntrospectedTable introspectedTable) {   
  24.         addGeneralMethodComment(method, introspectedTable.getFullyQualifiedTable());   
  25.     }   
  26.   
  27.     public void addGetterComment(Method method,   
  28.             IntrospectedTable introspectedTable,   
  29.             IntrospectedColumn introspectedColumn) {   
  30.         addGetterComment(method, introspectedTable.getFullyQualifiedTable(),   
  31.                 introspectedColumn.getRemarks());   
  32.     }   
  33.   
  34.     public void addSetterComment(Method method,   
  35.             IntrospectedTable introspectedTable,   
  36.             IntrospectedColumn introspectedColumn) {   
  37.         addSetterComment(method, introspectedTable.getFullyQualifiedTable(),   
  38.                 introspectedColumn.getRemarks());   
  39.     }   
  40.   
  41.     public void addClassComment(InnerClass innerClass,   
  42.             IntrospectedTable introspectedTable, boolean markAsDoNotDelete) {   
  43.         addClassComment(innerClass, introspectedTable.getFullyQualifiedTable(), markAsDoNotDelete);   
  44.     }  
public void addClassComment(InnerClass innerClass,
            IntrospectedTable introspectedTable) {
        addClassComment(innerClass, introspectedTable.getFullyQualifiedTable(), false);
    }

    public void addEnumComment(InnerEnum innerEnum,
            IntrospectedTable introspectedTable) {
        addEnumComment(innerEnum, introspectedTable.getFullyQualifiedTable());
    }

    public void addFieldComment(Field field,
            IntrospectedTable introspectedTable,
            IntrospectedColumn introspectedColumn) {
        addFieldComment(field, introspectedTable.getFullyQualifiedTable(),
                introspectedColumn.getRemarks());
    }

    public void addFieldComment(Field field, IntrospectedTable introspectedTable) {
        addFieldComment(field, introspectedTable.getFullyQualifiedTable());
    }

    public void addGeneralMethodComment(Method method,
            IntrospectedTable introspectedTable) {
        addGeneralMethodComment(method, introspectedTable.getFullyQualifiedTable());
    }

    public void addGetterComment(Method method,
            IntrospectedTable introspectedTable,
            IntrospectedColumn introspectedColumn) {
        addGetterComment(method, introspectedTable.getFullyQualifiedTable(),
                introspectedColumn.getRemarks());
    }

    public void addSetterComment(Method method,
            IntrospectedTable introspectedTable,
            IntrospectedColumn introspectedColumn) {
        addSetterComment(method, introspectedTable.getFullyQualifiedTable(),
                introspectedColumn.getRemarks());
    }

    public void addClassComment(InnerClass innerClass,
            IntrospectedTable introspectedTable, boolean markAsDoNotDelete) {
        addClassComment(innerClass, introspectedTable.getFullyQualifiedTable(), markAsDoNotDelete);
    }

 主要是把

Java代码 复制代码  收藏代码
  1. introspectedColumn.getActualColumnName()  
introspectedColumn.getActualColumnName()

 改成(利用数据库中的comment生成注释)

Java代码 复制代码  收藏代码
  1. introspectedColumn.getRemarks()  
introspectedColumn.getRemarks()

 

3)修改好,把生成的jar文件:"ibator-core-1.2.2-SNAPSHOT.jar",改名为"ibator.jar",在安装了ibator插件的Eclipse中,覆盖eclipse\plugins\org.apache.ibatis.ibator.core_1.2.1下的jar文件

4)测试:

   4.1) 数据库脚本:

 

Sql代码 复制代码  收藏代码
  1. create table  
  2. CREATE TABLE `brand` (   
  3.    `code` varchar(36) NOT NULL default '' COMMENT '代码',   
  4.    `logopath` varchar(80) default NULL COMMENT 'logo路径',   
  5.    `namevarchar(40) NOT NULL default '' COMMENT '名字',   
  6.    `visible` bit(1) NOT NULL COMMENT '是否可见',   
  7.    PRIMARY KEY  (`code`)   
  8.  ) ENGINE=InnoDB DEFAULT CHARSET=utf8   
  9.   
  10. create table  
  11. CREATE TABLE `employee` (   
  12.    `username` varchar(20) NOT NULL default '' COMMENT '用户名',   
  13.    `degree` varchar(10) default NULL COMMENT '等级',   
  14.    `email` varchar(50) default NULL COMMENT '电子邮箱',   
  15.    `gender` varchar(5) NOT NULL default '' COMMENT '性别',   
  16.    `imageName` varchar(41) default NULL COMMENT '图片名字',   
  17.    `passwordvarchar(20) NOT NULL default '' COMMENT '密码',   
  18.    `phone` varchar(20) default NULL COMMENT '电话',   
  19.    `realname` varchar(10) NOT NULL default '' COMMENT '真实姓名',   
  20.    `school` varchar(20) default NULL COMMENT '学校',   
  21.    `visible` bit(1) NOT NULL COMMENT '是否可见',   
  22.    `department_id` int(11) default NULL COMMENT '部门ID',   
  23.    `card_id` int(11) NOT NULL COMMENT '身份证',   
  24.    PRIMARY KEY  (`username`)   
  25.  ) ENGINE=InnoDB DEFAULT CHARSET=utf8   
create table
CREATE TABLE `brand` (
   `code` varchar(36) NOT NULL default '' COMMENT '代码',
   `logopath` varchar(80) default NULL COMMENT 'logo路径',
   `name` varchar(40) NOT NULL default '' COMMENT '名字',
   `visible` bit(1) NOT NULL COMMENT '是否可见',
   PRIMARY KEY  (`code`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8

create table
CREATE TABLE `employee` (
   `username` varchar(20) NOT NULL default '' COMMENT '用户名',
   `degree` varchar(10) default NULL COMMENT '等级',
   `email` varchar(50) default NULL COMMENT '电子邮箱',
   `gender` varchar(5) NOT NULL default '' COMMENT '性别',
   `imageName` varchar(41) default NULL COMMENT '图片名字',
   `password` varchar(20) NOT NULL default '' COMMENT '密码',
   `phone` varchar(20) default NULL COMMENT '电话',
   `realname` varchar(10) NOT NULL default '' COMMENT '真实姓名',
   `school` varchar(20) default NULL COMMENT '学校',
   `visible` bit(1) NOT NULL COMMENT '是否可见',
   `department_id` int(11) default NULL COMMENT '部门ID',
   `card_id` int(11) NOT NULL COMMENT '身份证',
   PRIMARY KEY  (`username`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 

 

   4.2)ibatorConfig.xml文件

 

Xml代码 复制代码  收藏代码
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE ibatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd" >  
  3. <ibatorConfiguration>  
  4.   
  5.     <classPathEntry  
  6.         location="D:/Eclipse/workspace/helios-3.6/test/lib/mysql_connector_java_5.jar" />  
  7.     <ibatorContext id="context1" targetRuntime="Ibatis2Java5">  
  8.   
  9.         <commentGenerator>  
  10.             <property name="suppressDate" value="true" />  
  11.         </commentGenerator>  
  12.   
  13.         <jdbcConnection driverClass="com.mysql.jdbc.Driver"  
  14.             connectionURL="jdbc:mysql://127.0.0.1:3306/test" userId="root"  
  15.             password="root">  
  16.         </jdbcConnection>  
  17.         <javaModelGenerator targetPackage="cn.zlj.ibatis.entity"  
  18.             targetProject="test" />  
  19.         <sqlMapGenerator targetPackage="cn.zlj.ibatis.sqlmap"  
  20.             targetProject="test" />  
  21.         <daoGenerator targetPackage="cn.zlj.ibatis.dao"  
  22.             targetProject="test" implementationPackage="cn.zlj.ibatis.dao.impl"  
  23.             type="spring" />  
  24.   
  25.         <table tableName="brand">  
  26.         </table>  
  27.         <table tableName="employee">  
  28.         </table>  
  29.     </ibatorContext>  
  30. </ibatorConfiguration>  
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE ibatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd" >
<ibatorConfiguration>

	<classPathEntry
		location="D:/Eclipse/workspace/helios-3.6/test/lib/mysql_connector_java_5.jar" />
	<ibatorContext id="context1" targetRuntime="Ibatis2Java5">

		<commentGenerator>
			<property name="suppressDate" value="true" />
		</commentGenerator>

		<jdbcConnection driverClass="com.mysql.jdbc.Driver"
			connectionURL="jdbc:mysql://127.0.0.1:3306/test" userId="root"
			password="root">
		</jdbcConnection>
		<javaModelGenerator targetPackage="cn.zlj.ibatis.entity"
			targetProject="test" />
		<sqlMapGenerator targetPackage="cn.zlj.ibatis.sqlmap"
			targetProject="test" />
		<daoGenerator targetPackage="cn.zlj.ibatis.dao"
			targetProject="test" implementationPackage="cn.zlj.ibatis.dao.impl"
			type="spring" />

		<table tableName="brand">
		</table>
		<table tableName="employee">
		</table>
	</ibatorContext>
</ibatorConfiguration>

 

  4.3)ibator生成文件

 

Java代码 复制代码  收藏代码
  1. package cn.zlj.ibatis.entity;   
  2.   
  3. public class Brand {   
  4.     /**  
  5.      * 代码  
  6.      */  
  7.     private String code;   
  8.   
  9.     /**  
  10.      * logo路径  
  11.      */  
  12.     private String logopath;   
  13.   
  14.     /**  
  15.      * 名字  
  16.      */  
  17.     private String name;   
  18.   
  19.     /**  
  20.      * 是否可见  
  21.      */  
  22.     private Boolean visible;   
  23.   
  24.     /**  
  25.      * 获取 代码  
  26.      *  
  27.      * @return   
  28.      */  
  29.     public String getCode() {   
  30.         return code;   
  31.     }   
  32.   
  33.     /**  
  34.      * 设置  代码  
  35.      *  
  36.      * @param code  
  37.      */  
  38.     public void setCode(String code) {   
  39.         this.code = code;   
  40.     }   
  41.   
  42.     /**  
  43.      * 获取 logo路径  
  44.      *  
  45.      * @return   
  46.      */  
  47.     public String getLogopath() {   
  48.         return logopath;   
  49.     }   
  50.   
  51.     /**  
  52.      * 设置  logo路径  
  53.      *  
  54.      * @param logopath  
  55.      */  
  56.     public void setLogopath(String logopath) {   
  57.         this.logopath = logopath;   
  58.     }   
  59.   
  60.     /**  
  61.      * 获取 名字  
  62.      *  
  63.      * @return   
  64.      */  
  65.     public String getName() {   
  66.         return name;   
  67.     }   
  68.   
  69.     /**  
  70.      * 设置  名字  
  71.      *  
  72.      * @param name  
  73.      */  
  74.     public void setName(String name) {   
  75.         this.name = name;   
  76.     }   
  77.   
  78.     /**  
  79.      * 获取 是否可见  
  80.      *  
  81.      * @return   
  82.      */  
  83.     public Boolean getVisible() {   
  84.         return visible;   
  85.     }   
  86.   
  87.     /**  
  88.      * 设置  是否可见  
  89.      *  
  90.      * @param visible  
  91.      */  
  92.     public void setVisible(Boolean visible) {   
  93.         this.visible = visible;   
  94.     }   
  95. }  
package cn.zlj.ibatis.entity;

public class Brand {
    /**
     * 代码
     */
    private String code;

    /**
     * logo路径
     */
    private String logopath;

    /**
     * 名字
     */
    private String name;

    /**
     * 是否可见
     */
    private Boolean visible;

    /**
     * 获取 代码
     *
     * @return 
     */
    public String getCode() {
        return code;
    }

    /**
     * 设置  代码
     *
     * @param code
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * 获取 logo路径
     *
     * @return 
     */
    public String getLogopath() {
        return logopath;
    }

    /**
     * 设置  logo路径
     *
     * @param logopath
     */
    public void setLogopath(String logopath) {
        this.logopath = logopath;
    }

    /**
     * 获取 名字
     *
     * @return 
     */
    public String getName() {
        return name;
    }

    /**
     * 设置  名字
     *
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取 是否可见
     *
     * @return 
     */
    public Boolean getVisible() {
        return visible;
    }

    /**
     * 设置  是否可见
     *
     * @param visible
     */
    public void setVisible(Boolean visible) {
        this.visible = visible;
    }
}

 

Java代码 复制代码  收藏代码
  1. package cn.zlj.ibatis.entity;   
  2.   
  3. public class Employee {   
  4.     /**  
  5.      * 用户名  
  6.      */  
  7.     private String username;   
  8.   
  9.     /**  
  10.      * 等级  
  11.      */  
  12.     private String degree;   
  13.   
  14.     /**  
  15.      * 电子邮箱  
  16.      */  
  17.     private String email;   
  18.   
  19.     /**  
  20.      * 性别  
  21.      */  
  22.     private String gender;   
  23.   
  24.     /**  
  25.      * 图片名字  
  26.      */  
  27.     private String imagename;   
  28.   
  29.     /**  
  30.      * 密码  
  31.      */  
  32.     private String password;   
  33.   
  34.     /**  
  35.      * 电话  
  36.      */  
  37.     private String phone;   
  38.   
  39.     /**  
  40.      * 真实姓名  
  41.      */  
  42.     private String realname;   
  43.   
  44.     /**  
  45.      * 学校  
  46.      */  
  47.     private String school;   
  48.   
  49.     /**  
  50.      * 是否可见  
  51.      */  
  52.     private Boolean visible;   
  53.   
  54.     /**  
  55.      * 部门ID  
  56.      */  
  57.     private Integer departmentId;   
  58.   
  59.     /**  
  60.      * 身份证  
  61.      */  
  62.     private Integer cardId;   
  63.   
  64.     /**  
  65.      * 获取 用户名  
  66.      *  
  67.      * @return   
  68.      */  
  69.     public String getUsername() {   
  70.         return username;   
  71.     }   
  72.   
  73.     /**  
  74.      * 设置  用户名  
  75.      *  
  76.      * @param username  
  77.      */  
  78.     public void setUsername(String username) {   
  79.         this.username = username;   
  80.     }   
  81.   
  82.     /**  
  83.      * 获取 等级  
  84.      *  
  85.      * @return   
  86.      */  
  87.     public String getDegree() {   
  88.         return degree;   
  89.     }   
  90.   
  91.     /**  
  92.      * 设置  等级  
  93.      *  
  94.      * @param degree  
  95.      */  
  96.     public void setDegree(String degree) {   
  97.         this.degree = degree;   
  98.     }   
  99.   
  100.     /**  
  101.      * 获取 电子邮箱  
  102.      *  
  103.      * @return   
  104.      */  
  105.     public String getEmail() {   
  106.         return email;   
  107.     }   
  108.   
  109.     /**  
  110.      * 设置  电子邮箱  
  111.      *  
  112.      * @param email  
  113.      */  
  114.     public void setEmail(String email) {   
  115.         this.email = email;   
  116.     }   
  117.   
  118.     /**  
  119.      * 获取 性别  
  120.      *  
  121.      * @return   
  122.      */  
  123.     public String getGender() {   
  124.         return gender;   
  125.     }   
  126.   
  127.     /**  
  128.      * 设置  性别  
  129.      *  
  130.      * @param gender  
  131.      */  
  132.     public void setGender(String gender) {   
  133.         this.gender = gender;   
  134.     }   
  135.   
  136.     /**  
  137.      * 获取 图片名字  
  138.      *  
  139.      * @return   
  140.      */  
  141.     public String getImagename() {   
  142.         return imagename;   
  143.     }   
  144.   
  145.     /**  
  146.      * 设置  图片名字  
  147.      *  
  148.      * @param imagename  
  149.      */  
  150.     public void setImagename(String imagename) {   
  151.         this.imagename = imagename;   
  152.     }   
  153.   
  154.     /**  
  155.      * 获取 密码  
  156.      *  
  157.      * @return   
  158.      */  
  159.     public String getPassword() {   
  160.         return password;   
  161.     }   
  162.   
  163.     /**  
  164.      * 设置  密码  
  165.      *  
  166.      * @param password  
  167.      */  
  168.     public void setPassword(String password) {   
  169.         this.password = password;   
  170.     }   
  171.   
  172.     /**  
  173.      * 获取 电话  
  174.      *  
  175.      * @return   
  176.      */  
  177.     public String getPhone() {   
  178.         return phone;   
  179.     }   
  180.   
  181.     /**  
  182.      * 设置  电话  
  183.      *  
  184.      * @param phone  
  185.      */  
  186.     public void setPhone(String phone) {   
  187.         this.phone = phone;   
  188.     }   
  189.   
  190.     /**  
  191.      * 获取 真实姓名  
  192.      *  
  193.      * @return   
  194.      */  
  195.     public String getRealname() {   
  196.         return realname;   
  197.     }   
  198.   
  199.     /**  
  200.      * 设置  真实姓名  
  201.      *  
  202.      * @param realname  
  203.      */  
  204.     public void setRealname(String realname) {   
  205.         this.realname = realname;   
  206.     }   
  207.   
  208.     /**  
  209.      * 获取 学校  
  210.      *  
  211.      * @return   
  212.      */  
  213.     public String getSchool() {   
  214.         return school;   
  215.     }   
  216.   
  217.     /**  
  218.      * 设置  学校  
  219.      *  
  220.      * @param school  
  221.      */  
  222.     public void setSchool(String school) {   
  223.         this.school = school;   
  224.     }   
  225.   
  226.     /**  
  227.      * 获取 是否可见  
  228.      *  
  229.      * @return   
  230.      */  
  231.     public Boolean getVisible() {   
  232.         return visible;   
  233.     }   
  234.   
  235.     /**  
  236.      * 设置  是否可见  
  237.      *  
  238.      * @param visible  
  239.      */  
  240.     public void setVisible(Boolean visible) {   
  241.         this.visible = visible;   
  242.     }   
  243.   
  244.     /**  
  245.      * 获取 部门ID  
  246.      *  
  247.      * @return   
  248.      */  
  249.     public Integer getDepartmentId() {   
  250.         return departmentId;   
  251.     }   
  252.   
  253.     /**  
  254.      * 设置  部门ID  
  255.      *  
  256.      * @param departmentId  
  257.      */  
  258.     public void setDepartmentId(Integer departmentId) {   
  259.         this.departmentId = departmentId;   
  260.     }   
  261.   
  262.     /**  
  263.      * 获取 身份证  
  264.      *  
  265.      * @return   
  266.      */  
  267.     public Integer getCardId() {   
  268.         return cardId;   
  269.     }   
  270.   
  271.     /**  
  272.      * 设置  身份证  
  273.      *  
  274.      * @param cardId  
  275.      */  
  276.     public void setCardId(Integer cardId) {   
  277.         this.cardId = cardId;   
  278.     }   
  279. }  
package cn.zlj.ibatis.entity;

public class Employee {
    /**
     * 用户名
     */
    private String username;

    /**
     * 等级
     */
    private String degree;

    /**
     * 电子邮箱
     */
    private String email;

    /**
     * 性别
     */
    private String gender;

    /**
     * 图片名字
     */
    private String imagename;

    /**
     * 密码
     */
    private String password;

    /**
     * 电话
     */
    private String phone;

    /**
     * 真实姓名
     */
    private String realname;

    /**
     * 学校
     */
    private String school;

    /**
     * 是否可见
     */
    private Boolean visible;

    /**
     * 部门ID
     */
    private Integer departmentId;

    /**
     * 身份证
     */
    private Integer cardId;

    /**
     * 获取 用户名
     *
     * @return 
     */
    public String getUsername() {
        return username;
    }

    /**
     * 设置  用户名
     *
     * @param username
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * 获取 等级
     *
     * @return 
     */
    public String getDegree() {
        return degree;
    }

    /**
     * 设置  等级
     *
     * @param degree
     */
    public void setDegree(String degree) {
        this.degree = degree;
    }

    /**
     * 获取 电子邮箱
     *
     * @return 
     */
    public String getEmail() {
        return email;
    }

    /**
     * 设置  电子邮箱
     *
     * @param email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * 获取 性别
     *
     * @return 
     */
    public String getGender() {
        return gender;
    }

    /**
     * 设置  性别
     *
     * @param gender
     */
    public void setGender(String gender) {
        this.gender = gender;
    }

    /**
     * 获取 图片名字
     *
     * @return 
     */
    public String getImagename() {
        return imagename;
    }

    /**
     * 设置  图片名字
     *
     * @param imagename
     */
    public void setImagename(String imagename) {
        this.imagename = imagename;
    }

    /**
     * 获取 密码
     *
     * @return 
     */
    public String getPassword() {
        return password;
    }

    /**
     * 设置  密码
     *
     * @param password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * 获取 电话
     *
     * @return 
     */
    public String getPhone() {
        return phone;
    }

    /**
     * 设置  电话
     *
     * @param phone
     */
    public void setPhone(String phone) {
        this.phone = phone;
    }

    /**
     * 获取 真实姓名
     *
     * @return 
     */
    public String getRealname() {
        return realname;
    }

    /**
     * 设置  真实姓名
     *
     * @param realname
     */
    public void setRealname(String realname) {
        this.realname = realname;
    }

    /**
     * 获取 学校
     *
     * @return 
     */
    public String getSchool() {
        return school;
    }

    /**
     * 设置  学校
     *
     * @param school
     */
    public void setSchool(String school) {
        this.school = school;
    }

    /**
     * 获取 是否可见
     *
     * @return 
     */
    public Boolean getVisible() {
        return visible;
    }

    /**
     * 设置  是否可见
     *
     * @param visible
     */
    public void setVisible(Boolean visible) {
        this.visible = visible;
    }

    /**
     * 获取 部门ID
     *
     * @return 
     */
    public Integer getDepartmentId() {
        return departmentId;
    }

    /**
     * 设置  部门ID
     *
     * @param departmentId
     */
    public void setDepartmentId(Integer departmentId) {
        this.departmentId = departmentId;
    }

    /**
     * 获取 身份证
     *
     * @return 
     */
    public Integer getCardId() {
        return cardId;
    }

    /**
     * 设置  身份证
     *
     * @param cardId
     */
    public void setCardId(Integer cardId) {
        this.cardId = cardId;
    }
}

 

Xml代码 复制代码  收藏代码
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >  
  3. <sqlMap namespace="brand" >  
  4.   <resultMap id="BaseResultMap" class="cn.zlj.ibatis.entity.Brand" >  
  5.     <result column="code" property="code" jdbcType="VARCHAR" />  
  6.     <result column="logopath" property="logopath" jdbcType="VARCHAR" />  
  7.     <result column="name" property="name" jdbcType="VARCHAR" />  
  8.     <result column="visible" property="visible" jdbcType="BIT" />  
  9.   </resultMap>  
  10.   <sql id="Example_Where_Clause" >  
  11.     <iterate property="oredCriteria" conjunction="or" prepend="where" removeFirstPrepend="iterate" >  
  12.       <isEqual property="oredCriteria[].valid" compareValue="true" >  
  13.         (   
  14.         <iterate prepend="and" property="oredCriteria[].criteriaWithoutValue" conjunction="and" >  
  15.           $oredCriteria[].criteriaWithoutValue[]$   
  16.         </iterate>  
  17.         <iterate prepend="and" property="oredCriteria[].criteriaWithSingleValue" conjunction="and" >  
  18.           $oredCriteria[].criteriaWithSingleValue[].condition$ #oredCriteria[].criteriaWithSingleValue[].value#   
  19.         </iterate>  
  20.         <iterate prepend="and" property="oredCriteria[].criteriaWithListValue" conjunction="and" >  
  21.           $oredCriteria[].criteriaWithListValue[].condition$   
  22.           <iterate property="oredCriteria[].criteriaWithListValue[].values" open="(" close=")" conjunction="," >  
  23.             #oredCriteria[].criteriaWithListValue[].values[]#   
  24.           </iterate>  
  25.         </iterate>  
  26.         <iterate prepend="and" property="oredCriteria[].criteriaWithBetweenValue" conjunction="and" >  
  27.           $oredCriteria[].criteriaWithBetweenValue[].condition$   
  28.           #oredCriteria[].criteriaWithBetweenValue[].values[0]# and   
  29.           #oredCriteria[].criteriaWithBetweenValue[].values[1]#   
  30.         </iterate>  
  31.         )   
  32.       </isEqual>  
  33.     </iterate>  
  34.   </sql>  
  35.   <sql id="Base_Column_List" >  
  36.     code, logopath, name, visible   
  37.   </sql>  
  38.   <select id="selectByExample" resultMap="BaseResultMap" parameterClass="cn.zlj.ibatis.entity.BrandExample" >  
  39.     select   
  40.     <isParameterPresent >  
  41.       <isEqual property="distinct" compareValue="true" >  
  42.         distinct   
  43.       </isEqual>  
  44.     </isParameterPresent>  
  45.     <include refid="brand.Base_Column_List" />  
  46.     from brand   
  47.     <isParameterPresent >  
  48.       <include refid="brand.Example_Where_Clause" />  
  49.       <isNotNull property="orderByClause" >  
  50.         order by $orderByClause$   
  51.       </isNotNull>  
  52.     </isParameterPresent>  
  53.   </select>  
  54.   <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterClass="cn.zlj.ibatis.entity.Brand" >  
  55.     select    
  56.     <include refid="brand.Base_Column_List" />  
  57.     from brand   
  58.     where code = #code:VARCHAR#   
  59.   </select>  
  60.   <delete id="deleteByPrimaryKey" parameterClass="cn.zlj.ibatis.entity.Brand" >  
  61.     delete from brand   
  62.     where code = #code:VARCHAR#   
  63.   </delete>  
  64.   <delete id="deleteByExample" parameterClass="cn.zlj.ibatis.entity.BrandExample" >  
  65.     delete from brand   
  66.     <include refid="brand.Example_Where_Clause" />  
  67.   </delete>  
  68.   <insert id="insert" parameterClass="cn.zlj.ibatis.entity.Brand" >  
  69.     insert into brand (code, logopath, name, visible)   
  70.     values (#code:VARCHAR#, #logopath:VARCHAR#, #name:VARCHAR#, #visible:BIT#)   
  71.   </insert>  
  72.   <insert id="insertSelective" parameterClass="cn.zlj.ibatis.entity.Brand" >  
  73.     insert into brand   
  74.     <dynamic prepend="(" >  
  75.       <isNotNull prepend="," property="code" >  
  76.         code   
  77.       </isNotNull>  
  78.       <isNotNull prepend="," property="logopath" >  
  79.         logopath   
  80.       </isNotNull>  
  81.       <isNotNull prepend="," property="name" >  
  82.         name   
  83.       </isNotNull>  
  84.       <isNotNull prepend="," property="visible" >  
  85.         visible   
  86.       </isNotNull>  
  87.       )   
  88.     </dynamic>  
  89.     values   
  90.     <dynamic prepend="(" >  
  91.       <isNotNull prepend="," property="code" >  
  92.         #code:VARCHAR#   
  93.       </isNotNull>  
  94.       <isNotNull prepend="," property="logopath" >  
  95.         #logopath:VARCHAR#   
  96.       </isNotNull>  
  97.       <isNotNull prepend="," property="name" >  
  98.         #name:VARCHAR#   
  99.       </isNotNull>  
  100.       <isNotNull prepend="," property="visible" >  
  101.         #visible:BIT#   
  102.       </isNotNull>  
  103.       )   
  104.     </dynamic>  
  105.   </insert>  
  106.   <select id="countByExample" parameterClass="cn.zlj.ibatis.entity.BrandExample" resultClass="java.lang.Integer" >  
  107.     select count(*) from brand   
  108.     <include refid="brand.Example_Where_Clause" />  
  109.   </select>  
  110.   <update id="updateByExampleSelective" >  
  111.     update brand   
  112.     <dynamic prepend="set" >  
  113.       <isNotNull prepend="," property="record.code" >  
  114.         code = #record.code:VARCHAR#   
  115.       </isNotNull>  
  116.       <isNotNull prepend="," property="record.logopath" >  
  117.         logopath = #record.logopath:VARCHAR#   
  118.       </isNotNull>  
  119.       <isNotNull prepend="," property="record.name" >  
  120.         name = #record.name:VARCHAR#   
  121.       </isNotNull>  
  122.       <isNotNull prepend="," property="record.visible" >  
  123.         visible = #record.visible:BIT#   
  124.       </isNotNull>  
  125.     </dynamic>  
  126.     <isParameterPresent >  
  127.       <include refid="brand.Example_Where_Clause" />  
  128.     </isParameterPresent>  
  129.   </update>  
  130.   <update id="updateByExample" >  
  131.     update brand   
  132.     set code = #record.code:VARCHAR#,   
  133.       logopath = #record.logopath:VARCHAR#,   
  134.       name = #record.name:VARCHAR#,   
  135.       visible = #record.visible:BIT#   
  136.     <isParameterPresent >  
  137.       <include refid="brand.Example_Where_Clause" />  
  138.     </isParameterPresent>  
  139.   </update>  
  140.   <update id="updateByPrimaryKeySelective" parameterClass="cn.zlj.ibatis.entity.Brand" >  
  141.     update brand   
  142.     <dynamic prepend="set" >  
  143.       <isNotNull prepend="," property="logopath" >  
  144.         logopath = #logopath:VARCHAR#   
  145.       </isNotNull>  
  146.       <isNotNull prepend="," property="name" >  
  147.         name = #name:VARCHAR#   
  148.       </isNotNull>  
  149.       <isNotNull prepend="," property="visible" >  
  150.         visible = #visible:BIT#   
  151.       </isNotNull>  
  152.     </dynamic>  
  153.     where code = #code:VARCHAR#   
  154.   </update>  
  155.   <update id="updateByPrimaryKey" parameterClass="cn.zlj.ibatis.entity.Brand" >  
  156.     update brand   
  157.     set logopath = #logopath:VARCHAR#,   
  158.       name = #name:VARCHAR#,   
  159.       visible = #visible:BIT#   
  160.     where code = #code:VARCHAR#   
  161.   </update>  
  162. </sqlMap>  
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
<sqlMap namespace="brand" >
  <resultMap id="BaseResultMap" class="cn.zlj.ibatis.entity.Brand" >
    <result column="code" property="code" jdbcType="VARCHAR" />
    <result column="logopath" property="logopath" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="visible" property="visible" jdbcType="BIT" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <iterate property="oredCriteria" conjunction="or" prepend="where" removeFirstPrepend="iterate" >
      <isEqual property="oredCriteria[].valid" compareValue="true" >
        (
        <iterate prepend="and" property="oredCriteria[].criteriaWithoutValue" conjunction="and" >
          $oredCriteria[].criteriaWithoutValue[]$
        </iterate>
        <iterate prepend="and" property="oredCriteria[].criteriaWithSingleValue" conjunction="and" >
          $oredCriteria[].criteriaWithSingleValue[].condition$ #oredCriteria[].criteriaWithSingleValue[].value#
        </iterate>
        <iterate prepend="and" property="oredCriteria[].criteriaWithListValue" conjunction="and" >
          $oredCriteria[].criteriaWithListValue[].condition$
          <iterate property="oredCriteria[].criteriaWithListValue[].values" open="(" close=")" conjunction="," >
            #oredCriteria[].criteriaWithListValue[].values[]#
          </iterate>
        </iterate>
        <iterate prepend="and" property="oredCriteria[].criteriaWithBetweenValue" conjunction="and" >
          $oredCriteria[].criteriaWithBetweenValue[].condition$
          #oredCriteria[].criteriaWithBetweenValue[].values[0]# and
          #oredCriteria[].criteriaWithBetweenValue[].values[1]#
        </iterate>
        )
      </isEqual>
    </iterate>
  </sql>
  <sql id="Base_Column_List" >
    code, logopath, name, visible
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterClass="cn.zlj.ibatis.entity.BrandExample" >
    select
    <isParameterPresent >
      <isEqual property="distinct" compareValue="true" >
        distinct
      </isEqual>
    </isParameterPresent>
    <include refid="brand.Base_Column_List" />
    from brand
    <isParameterPresent >
      <include refid="brand.Example_Where_Clause" />
      <isNotNull property="orderByClause" >
        order by $orderByClause$
      </isNotNull>
    </isParameterPresent>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterClass="cn.zlj.ibatis.entity.Brand" >
    select 
    <include refid="brand.Base_Column_List" />
    from brand
    where code = #code:VARCHAR#
  </select>
  <delete id="deleteByPrimaryKey" parameterClass="cn.zlj.ibatis.entity.Brand" >
    delete from brand
    where code = #code:VARCHAR#
  </delete>
  <delete id="deleteByExample" parameterClass="cn.zlj.ibatis.entity.BrandExample" >
    delete from brand
    <include refid="brand.Example_Where_Clause" />
  </delete>
  <insert id="insert" parameterClass="cn.zlj.ibatis.entity.Brand" >
    insert into brand (code, logopath, name, visible)
    values (#code:VARCHAR#, #logopath:VARCHAR#, #name:VARCHAR#, #visible:BIT#)
  </insert>
  <insert id="insertSelective" parameterClass="cn.zlj.ibatis.entity.Brand" >
    insert into brand
    <dynamic prepend="(" >
      <isNotNull prepend="," property="code" >
        code
      </isNotNull>
      <isNotNull prepend="," property="logopath" >
        logopath
      </isNotNull>
      <isNotNull prepend="," property="name" >
        name
      </isNotNull>
      <isNotNull prepend="," property="visible" >
        visible
      </isNotNull>
      )
    </dynamic>
    values
    <dynamic prepend="(" >
      <isNotNull prepend="," property="code" >
        #code:VARCHAR#
      </isNotNull>
      <isNotNull prepend="," property="logopath" >
        #logopath:VARCHAR#
      </isNotNull>
      <isNotNull prepend="," property="name" >
        #name:VARCHAR#
      </isNotNull>
      <isNotNull prepend="," property="visible" >
        #visible:BIT#
      </isNotNull>
      )
    </dynamic>
  </insert>
  <select id="countByExample" parameterClass="cn.zlj.ibatis.entity.BrandExample" resultClass="java.lang.Integer" >
    select count(*) from brand
    <include refid="brand.Example_Where_Clause" />
  </select>
  <update id="updateByExampleSelective" >
    update brand
    <dynamic prepend="set" >
      <isNotNull prepend="," property="record.code" >
        code = #record.code:VARCHAR#
      </isNotNull>
      <isNotNull prepend="," property="record.logopath" >
        logopath = #record.logopath:VARCHAR#
      </isNotNull>
      <isNotNull prepend="," property="record.name" >
        name = #record.name:VARCHAR#
      </isNotNull>
      <isNotNull prepend="," property="record.visible" >
        visible = #record.visible:BIT#
      </isNotNull>
    </dynamic>
    <isParameterPresent >
      <include refid="brand.Example_Where_Clause" />
    </isParameterPresent>
  </update>
  <update id="updateByExample" >
    update brand
    set code = #record.code:VARCHAR#,
      logopath = #record.logopath:VARCHAR#,
      name = #record.name:VARCHAR#,
      visible = #record.visible:BIT#
    <isParameterPresent >
      <include refid="brand.Example_Where_Clause" />
    </isParameterPresent>
  </update>
  <update id="updateByPrimaryKeySelective" parameterClass="cn.zlj.ibatis.entity.Brand" >
    update brand
    <dynamic prepend="set" >
      <isNotNull prepend="," property="logopath" >
        logopath = #logopath:VARCHAR#
      </isNotNull>
      <isNotNull prepend="," property="name" >
        name = #name:VARCHAR#
      </isNotNull>
      <isNotNull prepend="," property="visible" >
        visible = #visible:BIT#
      </isNotNull>
    </dynamic>
    where code = #code:VARCHAR#
  </update>
  <update id="updateByPrimaryKey" parameterClass="cn.zlj.ibatis.entity.Brand" >
    update brand
    set logopath = #logopath:VARCHAR#,
      name = #name:VARCHAR#,
      visible = #visible:BIT#
    where code = #code:VARCHAR#
  </update>
</sqlMap>

 

 

Java代码 复制代码  收藏代码
  1. package cn.zlj.ibatis.dao;   
  2.   
  3. import cn.zlj.ibatis.entity.Brand;   
  4. import cn.zlj.ibatis.entity.BrandExample;   
  5. import java.util.List;   
  6.   
  7. public interface BrandDAO {   
  8.     /**  
  9.      * brand countByExample  
  10.      */  
  11.     int countByExample(BrandExample example);   
  12.   
  13.     /**  
  14.      * brand deleteByExample  
  15.      */  
  16.     int deleteByExample(BrandExample example);   
  17.   
  18.     /**  
  19.      * brand deleteByPrimaryKey  
  20.      */  
  21.     int deleteByPrimaryKey(String code);   
  22.   
  23.     /**  
  24.      * brand insert  
  25.      */  
  26.     void insert(Brand record);   
  27.   
  28.     /**  
  29.      * brand insertSelective  
  30.      */  
  31.     void insertSelective(Brand record);   
  32.   
  33.     /**  
  34.      * brand selectByExample  
  35.      */  
  36.     List<Brand> selectByExample(BrandExample example);   
  37.   
  38.     /**  
  39.      * brand selectByPrimaryKey  
  40.      */  
  41.     Brand selectByPrimaryKey(String code);   
  42.   
  43.     /**  
  44.      * brand updateByExampleSelective  
  45.      */  
  46.     int updateByExampleSelective(Brand record, BrandExample example);   
  47.   
  48.     /**  
  49.      * brand updateByExample  
  50.      */  
  51.     int updateByExample(Brand record, BrandExample example);   
  52.   
  53.     /**  
  54.      * brand updateByPrimaryKeySelective  
  55.      */  
  56.     int updateByPrimaryKeySelective(Brand record);   
  57.   
  58.     /**  
  59.      * brand updateByPrimaryKey  
  60.      */  
  61.     int updateByPrimaryKey(Brand record);   
  62. }  
package cn.zlj.ibatis.dao;

import cn.zlj.ibatis.entity.Brand;
import cn.zlj.ibatis.entity.BrandExample;
import java.util.List;

public interface BrandDAO {
    /**
     * brand countByExample
     */
    int countByExample(BrandExample example);

    /**
     * brand deleteByExample
     */
    int deleteByExample(BrandExample example);

    /**
     * brand deleteByPrimaryKey
     */
    int deleteByPrimaryKey(String code);

    /**
     * brand insert
     */
    void insert(Brand record);

    /**
     * brand insertSelective
     */
    void insertSelective(Brand record);

    /**
     * brand selectByExample
     */
    List<Brand> selectByExample(BrandExample example);

    /**
     * brand selectByPrimaryKey
     */
    Brand selectByPrimaryKey(String code);

    /**
     * brand updateByExampleSelective
     */
    int updateByExampleSelective(Brand record, BrandExample example);

    /**
     * brand updateByExample
     */
    int updateByExample(Brand record, BrandExample example);

    /**
     * brand updateByPrimaryKeySelective
     */
    int updateByPrimaryKeySelective(Brand record);

    /**
     * brand updateByPrimaryKey
     */
    int updateByPrimaryKey(Brand record);
}

 

 

Java代码 复制代码  收藏代码
  1. package cn.zlj.ibatis.dao.impl;   
  2.   
  3. import cn.zlj.ibatis.dao.BrandDAO;   
  4. import cn.zlj.ibatis.entity.Brand;   
  5. import cn.zlj.ibatis.entity.BrandExample;   
  6. import java.util.List;   
  7. import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;   
  8.   
  9. public class BrandDAOImpl extends SqlMapClientDaoSupport implements BrandDAO {   
  10.   
  11.     /**  
  12.      * brand BrandDAOImpl  
  13.      */  
  14.     public BrandDAOImpl() {   
  15.         super();   
  16.     }   
  17.   
  18.     /**  
  19.      * brand countByExample  
  20.      */  
  21.     public int countByExample(BrandExample example) {   
  22.         Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("brand.countByExample", example);   
  23.         return count;   
  24.     }   
  25.   
  26.     /**  
  27.      * brand deleteByExample  
  28.      */  
  29.     public int deleteByExample(BrandExample example) {   
  30.         int rows = getSqlMapClientTemplate().delete("brand.deleteByExample", example);   
  31.         return rows;   
  32.     }   
  33.   
  34.     /**  
  35.      * brand deleteByPrimaryKey  
  36.      */  
  37.     public int deleteByPrimaryKey(String code) {   
  38.         Brand _key = new Brand();   
  39.         _key.setCode(code);   
  40.         int rows = getSqlMapClientTemplate().delete("brand.deleteByPrimaryKey", _key);   
  41.         return rows;   
  42.     }   
  43.   
  44.     /**  
  45.      * brand insert  
  46.      */  
  47.     public void insert(Brand record) {   
  48.         getSqlMapClientTemplate().insert("brand.insert", record);   
  49.     }   
  50.   
  51.     /**  
  52.      * brand insertSelective  
  53.      */  
  54.     public void insertSelective(Brand record) {   
  55.         getSqlMapClientTemplate().insert("brand.insertSelective", record);   
  56.     }   
  57.   
  58.     /**  
  59.      * brand selectByExample  
  60.      */  
  61.     @SuppressWarnings("unchecked")   
  62.     public List<Brand> selectByExample(BrandExample example) {   
  63.         List<Brand> list = getSqlMapClientTemplate().queryForList("brand.selectByExample", example);   
  64.         return list;   
  65.     }   
  66.   
  67.     /**  
  68.      * brand selectByPrimaryKey  
  69.      */  
  70.     public Brand selectByPrimaryKey(String code) {   
  71.         Brand _key = new Brand();   
  72.         _key.setCode(code);   
  73.         Brand record = (Brand) getSqlMapClientTemplate().queryForObject("brand.selectByPrimaryKey", _key);   
  74.         return record;   
  75.     }   
  76.   
  77.     /**  
  78.      * brand updateByExampleSelective  
  79.      */  
  80.     public int updateByExampleSelective(Brand record, BrandExample example) {   
  81.         UpdateByExampleParms parms = new UpdateByExampleParms(record, example);   
  82.         int rows = getSqlMapClientTemplate().update("brand.updateByExampleSelective", parms);   
  83.         return rows;   
  84.     }   
  85.   
  86.     /**  
  87.      * brand updateByExample  
  88.      */  
  89.     public int updateByExample(Brand record, BrandExample example) {   
  90.         UpdateByExampleParms parms = new UpdateByExampleParms(record, example);   
  91.         int rows = getSqlMapClientTemplate().update("brand.updateByExample", parms);   
  92.         return rows;   
  93.     }   
  94.   
  95.     /**  
  96.      * brand updateByPrimaryKeySelective  
  97.      */  
  98.     public int updateByPrimaryKeySelective(Brand record) {   
  99.         int rows = getSqlMapClientTemplate().update("brand.updateByPrimaryKeySelective", record);   
  100.         return rows;   
  101.     }   
  102.   
  103.     /**  
  104.      * brand updateByPrimaryKey  
  105.      */  
  106.     public int updateByPrimaryKey(Brand record) {   
  107.         int rows = getSqlMapClientTemplate().update("brand.updateByPrimaryKey", record);   
  108.         return rows;   
  109.     }   
  110.   
  111.     /**  
  112.      * brand  
  113.      */  
  114.     protected static class UpdateByExampleParms extends BrandExample {   
  115.         private Object record;   
  116.   
  117.         public UpdateByExampleParms(Object record, BrandExample example) {   
  118.             super(example);   
  119.             this.record = record;   
  120.         }   
  121.   
  122.         public Object getRecord() {   
  123.             return record;   
  124.         }   
  125.     }   
  126. }  
package cn.zlj.ibatis.dao.impl;

import cn.zlj.ibatis.dao.BrandDAO;
import cn.zlj.ibatis.entity.Brand;
import cn.zlj.ibatis.entity.BrandExample;
import java.util.List;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class BrandDAOImpl extends SqlMapClientDaoSupport implements BrandDAO {

    /**
     * brand BrandDAOImpl
     */
    public BrandDAOImpl() {
        super();
    }

    /**
     * brand countByExample
     */
    public int countByExample(BrandExample example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("brand.countByExample", example);
        return count;
    }

    /**
     * brand deleteByExample
     */
    public int deleteByExample(BrandExample example) {
        int rows = getSqlMapClientTemplate().delete("brand.deleteByExample", example);
        return rows;
    }

    /**
     * brand deleteByPrimaryKey
     */
    public int deleteByPrimaryKey(String code) {
        Brand _key = new Brand();
        _key.setCode(code);
        int rows = getSqlMapClientTemplate().delete("brand.deleteByPrimaryKey", _key);
        return rows;
    }

    /**
     * brand insert
     */
    public void insert(Brand record) {
        getSqlMapClientTemplate().insert("brand.insert", record);
    }

    /**
     * brand insertSelective
     */
    public void insertSelective(Brand record) {
        getSqlMapClientTemplate().insert("brand.insertSelective", record);
    }

    /**
     * brand selectByExample
     */
    @SuppressWarnings("unchecked")
    public List<Brand> selectByExample(BrandExample example) {
        List<Brand> list = getSqlMapClientTemplate().queryForList("brand.selectByExample", example);
        return list;
    }

    /**
     * brand selectByPrimaryKey
     */
    public Brand selectByPrimaryKey(String code) {
        Brand _key = new Brand();
        _key.setCode(code);
        Brand record = (Brand) getSqlMapClientTemplate().queryForObject("brand.selectByPrimaryKey", _key);
        return record;
    }

    /**
     * brand updateByExampleSelective
     */
    public int updateByExampleSelective(Brand record, BrandExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("brand.updateByExampleSelective", parms);
        return rows;
    }

    /**
     * brand updateByExample
     */
    public int updateByExample(Brand record, BrandExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("brand.updateByExample", parms);
        return rows;
    }

    /**
     * brand updateByPrimaryKeySelective
     */
    public int updateByPrimaryKeySelective(Brand record) {
        int rows = getSqlMapClientTemplate().update("brand.updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * brand updateByPrimaryKey
     */
    public int updateByPrimaryKey(Brand record) {
        int rows = getSqlMapClientTemplate().update("brand.updateByPrimaryKey", record);
        return rows;
    }

    /**
     * brand
     */
    protected static class UpdateByExampleParms extends BrandExample {
        private Object record;

        public UpdateByExampleParms(Object record, BrandExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}

 

OK,修改完成,去掉了很多原来自动生成的注释。

 

可以自己写实现org.apache.ibatis.ibator.api.CommentGenerato

或者重写org.apache.ibatis.ibator.internal.DefaultCommentGenerator这个类的

Java代码 复制代码  收藏代码
  1. public void addClassComment(InnerClass innerClass,   
  2.             IntrospectedTable introspectedTable)    
  3.   
  4.     public void addEnumComment(InnerEnum innerEnum,   
  5.             IntrospectedTable introspectedTable)    
  6.   
  7.     public void addFieldComment(Field field,   
  8.             IntrospectedTable introspectedTable,   
  9.             IntrospectedColumn introspectedColumn)    
  10.   
  11.     public void addFieldComment(Field field, IntrospectedTable introspectedTable);   
  12.   
  13.     public void addGeneralMethodComment(Method method,   
  14.             IntrospectedTable introspectedTable) ;   
  15.   
  16.     public void addGetterComment(Method method,   
  17.             IntrospectedTable introspectedTable,   
  18.             IntrospectedColumn introspectedColumn) ;   
  19.   
  20.     public void addSetterComment(Method method,   
  21.             IntrospectedTable introspectedTable,   
  22.             IntrospectedColumn introspectedColumn) ;   
  23.   
  24.     public void addClassComment(InnerClass innerClass,   
  25.             IntrospectedTable introspectedTable, boolean markAsDoNotDelete) ;  
public void addClassComment(InnerClass innerClass,
            IntrospectedTable introspectedTable) 

    public void addEnumComment(InnerEnum innerEnum,
            IntrospectedTable introspectedTable) 

    public void addFieldComment(Field field,
            IntrospectedTable introspectedTable,
            IntrospectedColumn introspectedColumn) 

    public void addFieldComment(Field field, IntrospectedTable introspectedTable);

    public void addGeneralMethodComment(Method method,
            IntrospectedTable introspectedTable) ;

    public void addGetterComment(Method method,
            IntrospectedTable introspectedTable,
            IntrospectedColumn introspectedColumn) ;

    public void addSetterComment(Method method,
            IntrospectedTable introspectedTable,
            IntrospectedColumn introspectedColumn) ;

    public void addClassComment(InnerClass innerClass,
            IntrospectedTable introspectedTable, boolean markAsDoNotDelete) ;

 ibator1.2.2与以前的版本的主要改变就是以上这几个方法,原来的这种

addFieldComment(Field field, FullyQualifiedTable table, String columnName)方法,

在下一版本中就会被去掉了。

 

 

Java代码 复制代码  收藏代码
  1. /**  
  2.      * Method from the old version of the interface.  
  3.      *   
  4.      * TODO - remove in release 1.2.3  
  5.      *   
  6.      * @deprecated as of version 1.2.2.  
  7.      * @see DefaultCommentGenerator#addFieldComment(Field, IntrospectedTable, IntrospectedColumn)  
  8.      */  
  9.     public void addFieldComment(Field field, FullyQualifiedTable table, String columnName) {   
  10. 。。。。。   
  11. }  

你可能感兴趣的:(bat)