`
awfrun
  • 浏览: 80074 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

ibatis2.3入门

阅读更多

1.需要的包在附件中

2.eclipse自动生成映射文件

Abator安装

Abator 的官方网站:http://ibatis.apache.org/ibator.html

在eclipse的菜单栏中可以看到: File > New > Abator  for iBATIS Configuration File,  即安装成功

自动生成abatorConfig.xml

 

替换abatorConfig.xml中的???:

①. 填写driverClass(jdbc驱动,例如oracle的就是oracle.jdbc.driver.OracleDriver)
②. 填写connectionURL(连接字符串,例如oracle的就是jdbc:oracle:thin:@localhost:1521:orcl)
③. 填写classPathEntry的location(jdbc驱动jar包的位置,例如D:/myproject/test/WEB-INF/lib/ojdbc14.jar)
④. 填写javaModelGenerator,生成的DTO(java model 类)
    targetPackage:目标包的位置,如 com.test.model
    targetProject:目标工程名称,填写配置文件所在的eclipse工程名,如test/src
⑤. 填写sqlMapGenerator ,生成的xml sqlmap的相关配置
    targetPackage:目标位置,如 com.test.sqlmap
    targetProject:目标工程名称,填写配置文件所在的eclipse工程名,如test/src
⑥. 填写daoGenerator ,生成的DAO的相关配置
    type:生成的dao实现的类型,如果你使用spring的话写SPRING,否则写IBATIS
    targetPackage:目标位置,如 com.test.dao
    targetProject:目标工程名称,填写配置文件所在的eclipse工程名,如test/src
⑦. 配置相关数据库的表
    schema:数据库schema,oracle就是填写数据库的用户名,如test
    tableName:表明,如ttest
    catalog:数据库名,如orcl
    注释掉<columnOverride column="???" property="???" />,不写columnOverride的话生成所有字段

 

 

<?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="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1/test?useUnicode=true&amp;characterEncoding=gbk" userId="root" password="admin" >
      <classPathEntry location="D:\soft\jar\mysql-connector-java-5.0.0.jar" />
    </jdbcConnection>
    <javaModelGenerator targetPackage="com.test.model" targetProject="ibatis/src" />
    <sqlMapGenerator targetPackage="com.test.sqlmap " targetProject="ibatis/src" />
    <daoGenerator targetPackage=" com.test.dao" targetProject="ibatis/src" type="GENERIC-CI" />
    <table schema="test" tableName="admin" >
    <!--
      <columnOverride column="???" property="???" />
      -->
    </table>
  </abatorContext>
</abatorConfiguration>

 

其它说明:

type        生成dao文件的类型,可选择IBATIS、SPRING、GENERIC-CI、GENERIC-SI。默认使用GENERIC-CI
                      dao类在构造器中获取 SqlMapClient

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics