*******************************************************
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..
********************************