注册 登录  
 加关注

网易博客网站关停、迁移的公告:

将从2018年11月30日00:00起正式停止网易博客运营
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

一路奔跑

奔跑着一路向前...

 
 
 

日志

 
 

Ibatis之Eclipse开发插件——Ibator   

2009-09-22 10:50:08|  分类: Java进级中 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
1、插件简介

Ibator is a code generator for iBATIS. Ibator will introspect a database table (or many tables) and will generate iBATIS artifacts that can be used to access the table(s). This abates some of the initial nuisance of setting up objects and configuration files to interact with database tables. Ibator seeks to make a major impact on the large percentage of database operations that are simple CRUD (Create, Retrieve, Update, Delete). You will still need to hand code SQL and objects for custom queries, or stored procedures.

Ibator产生的文件有:
  • SqlMap XML Files
  • Java Classes to match the primary key and fields of the table(s)
  • DAO Classes that use the above objects (optional)
Ibator can run as a standalone JAR file, or as an Ant task, or as an Eclipse plugin.

2、插件安装

        我们可以借助Eclipse来安装,当然也可以直接到http://ibatis.apache.org/ibator.html下载,然后解压,将相应的的文件拷贝到eclipse目录。

        2.1、Eclipse自动安装

If you've already installed a prior version of Ibator, simply run the Eclipse Update tool and the new version will be found automatically.
If you've not previously installed Ibator, use the built in Eclipse install support by following these steps:
  • Take the "Help>Software Updates..." Menu Option
  • Select the "Available Software" Tab
  • Press the "Add Site" button
  • Enter the following information:
    Location:
    http://ibatis.apache.org/tools/ibator
  • Press OK
  • Check the box next to "Apache iBATIS Ibator Feature"
  • Press the "Install" button
  • Follow the remainder of the install wizard


        2.2、Eclipse手动安装

The automatic install is much preferred, but you can also install Ibator manually if you desire. To install manually, download the file IbatorForEclipse1.2.1.zip and unzip the file to some convenient location. After unzipping the update site archive, follow these steps in Eclipse:
  • Take the "Help>Software Updates..." Menu Option
  • Select the "Available Software" Tab
  • Press the "Add Site" button
  • Press the "Local" button
  • Navigate to the location where you unzipped the site archive
  • Press OK
  • Check the box next to "Apache iBATIS Ibator Feature"
  • Press the "Install" button
  • Follow the remainder of the install wizard
3、ibatorConfig.xml文件配置示例(该示例基于Maven项目管理)

引用

<?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>

 <!--配置驱动jar-->
 <classPathEntry
  location="${user.home}/.m2/repository/postgresql/postgresql/8.1-408.jdbc3/postgresql-8.1-408.jdbc3.jar" />

 <ibatorContext id="context1">
  <!--数据库连接-->
  <jdbcConnection driverClass="org.postgresql.Driver"   connectionURL="jdbc:postgresql://127.0.0.1:5432/test_site" userId="test"   password="123456"> </jdbcConnection>

  <javaTypeResolver>
   <property name="forceBigDecimals" value="false" />
  </javaTypeResolver>

  <!--产生Java类,该类的属性与数据库的列名一一对应,targetPackage为产生的类的包名-->
  <javaModelGenerator targetPackage="org.jpxx.test.common.dal.ibatis.model"
   targetProject="test/src/main/java/">
   <property name="enableSubPackages" value="true" />
   <property name="trimStrings" value="true" />
  </javaModelGenerator>

 <!--SqlMap XML 文件-->
  <sqlMapGenerator targetPackage="sqlmap"
   targetProject="test/src/main/resources/">
   <property name="enableSubPackages" value="true" />
  </sqlMapGenerator>

 <!--DAO类的产生配置-->
  <daoGenerator targetPackage="org.jpxx.test.common.dal.ibatis.dao"
   implementationPackage="org.jpxx.sec.common.dal.ibatis.dao.impl"
   targetProject="test/src/main/java/" type="GENERIC-SI">
   <property name="enableSubPackages" value="true" />
  </daoGenerator>

  <!-- 数据库表的相关配置 -->
  <table schema="" tableName="admin" domainObjectName="Admin">
   <property name="useActualColumnNames" value="false" />
   <property name="enableInsert" value="true" />
   <property name="enableSelectByPrimaryKey" value="true" />
   <property name="enableUpdateByPrimaryKey" value="true" />
   <property name="enableDeleteByPrimaryKey" value="true" />
  </table>
  
  <table schema="" tableName="college_image" domainObjectName="Photo">
   <property name="useActualColumnNames" value="false" />
   <property name="enableInsert" value="true" />
   <property name="enableSelectByPrimaryKey" value="true" />
   <property name="enableUpdateByPrimaryKey" value="true" />
   <property name="enableDeleteByPrimaryKey" value="true" />
   
   <property name="enableSelectByExample" value="false" />
   <property name="enableDeleteByExample" value="false" />
   <property name="enableCountByExample" value="false" />
   <property name="enableUpdateByExample" value="false" />
   <property name="selectByExampleQueryId" value="false" />
  </table>
 <!-- 数据库表的相关配置结束 -->

 </ibatorContext>
</ibatorConfiguration>


4、执行Ibator

        如图所示:


Ibatis之Eclipse开发插件——Ibator  - 誠者無敌 - 一路奔跑


5、参考文献

http://ibatis.apache.org/ibator.html
  评论这张
 
阅读(1757)| 评论(1)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018