zoukankan      html  css  js  c++  java
  • ibatis代码生成工具abator使用全过程

    *******************************************************
    1) 下载网站,按以下步骤安装
    *****************************************************
               
    http://ibatis.apache.org/abator.html

                    Manual Eclipse Install

      The automatic install is much preferred, but you can also install Abator manually if you         desire. To install manually, download the file AbatorForEclipse1.0.0.zip and unzip the file to some convenient location. This file is a zipped version of the update site and includes both version 1.0.0, and the prior version 0.6.5. After unzipping the update site archive, follow these steps in Eclipse:

       1. Take the "Help>Software Updates>Find and Install" Menu Option
       2. Select the "Search for new features to install" radio button, press "Next"
       3. Press the "New Local Site" button
       4. Navigate to the location where you unzipped the file.
       5. Press OK
       6. Follow the remainder of the install wizard


    ****************************************
    2)配置abator  ----------abatroConfig.xml
    ********************************
    新建一种文件类型:Abator for iBATIS Configuration File

    当前项目下生成abatroConfig.xml文件;




    -------------------abatroConfig.xml---------------

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE abatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"
      "http://ibatis.apache.org/dtd/abator-config_1_0.dtd">

    <abatorConfiguration>
      <abatorContext>    <!-- TODO: Add Database Connection Information -->
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
            connectionURL="jdbc:mysql://127.0.0.1:3306/ctwob"
            userId="root"
            password="fu">
          <classPathEntry location="E:\2007new\eclipse\workspace\c2bend\WebRoot\WEB-INF\lib\mysql-connector-java-3.1.8-bin.jar" />
        </jdbcConnection>

        <javaModelGenerator targetPackage="com.qq.model" targetProject="c2bend" />
        <sqlMapGenerator targetPackage="com.qq.xml" targetProject="c2bend" />
        <daoGenerator type="IBATIS" targetPackage="com.qq.dao" targetProject="c2bend" />

        <table schema="first" tableName="ask">
        
        </table>

      </abatorContext>
    </abatorConfiguration>


    节点说明:
          
           <jdbcConnection   
                 driverClass="com.mysql.jdbc.Driver"           /***driverClass驱动类型 为mysql
                connectionURL="jdbc:mysql://127.0.0.1:3306/ctwob"   /****connectionURL为 mysql  数据库为ctwob
                userId="root"     /**用户名                               
                password="fuzhou708">  /**密码
                  <classPathEntry  location=     /**mysql的jdbc类包   mysql-connector-java-3.1.8-bin.jar            

                         "E:\2007new\eclipse\workspace\c2bend\WebRoot\WEB-INF\lib\mysql-connector-java-3.1.8-bin.jar"  />
        </jdbcConnection>



    4:在 jdbcConnection 中设置要mapping的数据库的jdbc连接
      classPathEntry 是你的jdbc driver类路径
    5:javaModelGenerator,sqlMapGenerator,daoGenerator 分别设置 java dataObject、sql mapping文件和 DAO 接口、实现类的生成位置:targetPackage 目标包,targetProject:eclipse项目
    6:daoGenerator 中可以设置属性  type: ibatis 或 spring 指定生成的dao实现类是使用com.ibatis.dao.client.template.SqlMapDaoTemplate
    还是org.springframework.orm.ibatis.support.SqlMapClientDaoSupport
    7: table 中 tableName 指定要处理的表名
    可以有多个table
    8:table中可以包含子元素 generatedKey: 使Insert方法可以返回值--由指定的column mapping
    9:generatedKey中的sqlStatement属性可以是获取sequence的SQL,也可以是获取自增值的SQL
      比如:Oracle的 select theSequence.nextVal from dual
           SQLServer的 SELECT @@IDENTITY as  column_name
    -------------------------------------------------




    *************************
    3)保存文件,选中文件,右键菜单选择Generate iBATIS Artifacts! ok..
    ********************************

  • 相关阅读:
    搜索引擎的变化 【转载】
    转贴:Apache重负荷服务器应如何优化
    开源WebGIS系统构建工具集合
    linux命令大全
    英语新闻常用搜索引擎 【转载】
    转载王垠的《完全用GNU/Linux工作》!!!
    国内外搜索引擎论坛 【转载】
    刚刚申请的WebGIS应用QQ群,最大用户80,欢迎加入啊!
    转贴:用Apache反向代理设置对外的WWW和文件服务器
    sourceforge.net上的GeoServer的下载地址列表
  • 原文地址:https://www.cnblogs.com/smallfa/p/872998.html
Copyright © 2011-2022 走看看