abator安装及详解

1.首先,要把这个abator插件下载到myeclipse中

方法: 点击myeclipse工具栏中的help -->
software updates -->find and install-->search for new features to install -->
new remote site --> name = abator --> url = http://ibatis.apache.org/tools/abator
-->finish  下载后,自动安装即可!

 

注意事项:在运行插件过程报错

java.sql.SQLException: ORA-00604: error occurred

java.sql.SQLException: ORA-12705: invalid or unknown NLS parameter value specified

解决办法:
出现这种问题的主要原因是MyEclipse在启动时候,语言编码是在[MyEclipse路径]/eclipse/eclipse.ini文件中加载的,而国别编码是从系统的区域设置中得到的.如果MyEclipse默认启动参数为"-Duser.language=en",而操作系统设为"中文(中国)"MyEclipse加载后的信息就是"en_CN",这样就会出现上述问题,所以只要将两边的设置改成一致的,就可以解决上述问题.以上的解决方法是统一为en_US.
你也可以就系统的区域设置定为"中文(中国)",修改eclipse.ini文件,"-Duser.language=en"修改为"-Duser.language=zh",这样在MyEclipse加载后的Configuration Details信息就统一为zh_CN,"osgi.nl=zh_CN" ,可以解决此问题.


2.创建abatorConfig.xml文件

abator插件安装成功后会在新建中看到,右键点击src新建会在abator for iBatis wizards文件夹下看

到一个前面显示黑色星星的东西 abator for iBatis configuration File,点击后会建一个

abatorConfig.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 >
    <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
    connectionURL="jdbc:oracle:thin:@192.168.1.129:1521:uplot"
    userId="id5"
    password="wwwid5cn" >
      <classPathEntry location="E:/workspace/workplace_1/spring_struts1.2_ibatise/WebRoot/WEB-INF/lib/ojdbc14.jar" />
    </jdbcConnection>
   
    <javaModelGenerator targetPackage="com.beijing.userinfo.web.form" targetProject="spring_struts1.2_ibatise" />
    <sqlMapGenerator targetPackage="com.beijing.userinfo.sqlmap" targetProject="spring_struts1.2_ibatise" />
    <daoGenerator targetPackage="com.beijing.userinfo.dao" targetProject="spring_struts1.2_ibatise" type="spring" />
 
     <table  tableName="USER_INFO">
    </table>
  </abatorContext>
</abatorConfiguration>

3.配置完毕,创建相应的文件

--> 右键点击abatorConfig.xml文件,点击generate iBatis artfacts就会在相应的配置目

4、配置文件详解:
(1)<!-- mysql数据库连接,本地数据库mydb -->
                 <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                              connectionURL="jdbc:mysql:///mydb" userId="root" password="">
                      <classPathEntry location=
                         "/WinApps/mysql-5.0.22-win32/mysql-connector-java-5.0.0-beta-bin.jar" />
                 </jdbcConnection>
(2)<!-- 生成domain对象,存放在com.tomliu.test.domain -->
                 <javaModelGenerator targetPackage="com.tomliu.test.domain"
                                                         targetProject="Abator Test Project">
                      <property name="enableSubPackages" value="false" />
                      <!-- domain对象的属性如果是string类型,去掉空格 -->
                      <property name="trimStrings" value="true" />
                 </javaModelGenerator>
(3)<!-- 生成sql和配置信息,存放在com.tomliu.test.sqlmapdao.sql -->
                 <sqlMapGenerator targetPackage="com.tomliu.test.sqlmapdao.sql"
                                                         targetProject="Abator Test Project">
                      <property name="enableSubPackages" value="false" />
                 </sqlMapGenerator>
(4)<!-- 生成dao接口和dao实现类,存放在com.tomliu.test.dao -->
                 <!-- dao类型常用SPRING或者IBATIS -->
                 <daoGenerator type="IBATIS" targetPackage="com.tomliu.test.dao"
                                                          targetProject="Abator Test Project">
                      <property name="enableSubPackages" value="false" />
                 </daoGenerator>
(5)<!-- 下面是转换的每个数据库实体 -->
                 <!-- 表login_user -->
                 <table schema="mysql" tableName="login_user" domainObjectName="User"
                                   enableInsert="true"
                                   enableSelectByPrimaryKey="true"
                                   enableSelectByExample="true"
                                   enableUpdateByPrimaryKey="true"
                                   enableDeleteByPrimaryKey="true"
                                   enableDeleteByExample="true">
                      <property name="useActualColumnNames" value="true" />
                      <!-- 数据库自动维护的列 -->
                      <generatedKey column="ID" sqlStatement="DB2" identity="true" />
                      <!-- 重写的列,列名重写,DATE_FIELD和startDate对应 -->
                      <columnOverride column="DATE_FIELD" property="startDate" />
                      <!-- 忽略的列 -->
                      <ignoreColumn column="FRED" />
                      <!-- 重写的列,列类型重写 -->
                      <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" />
                 </table>
(6)<!-- 表login_logs -->
                 <!-- 没有schema,不需要按照Example查询和删除 -->
                 <table schema="" tableName="login_logs" domainObjectName="LoginLogs"
                                   enableSelectByExample="false" enableDeleteByExample="false">
                             <property name="useActualColumnNames" value="true" />
                 </table>

你可能感兴趣的:(ibatis,abator)