Ibator of Ibatis

Ibator是一款用于iBATIS的代码生成工具,它能够通过分析数据库表结构生成相应的iBATIS配置文件和Java类,从而简化了与数据库交互的初始设置过程。Ibator主要针对简单的增删改查操作进行优化,但仍需手动编写特定查询的SQL语句。
 
Ibator
 
In ibatis home it says like this:
 
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 will generate: 

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. 
 
Compare to hibernate tool, they are very similar, but i think ibator is more easier to use, and may be it more simple in function than hibernate tool. 
 
By which docs, which say something difference between Ibator and Abator in "Migrating from Abator", it should be take a point. And in Ibatis home intro  which should use jdk1.5, and in fact i using 1.56and make a demo success.
 
A HelloWorld of Ibator1.2
 
Before do it, you should install this plugin to eclispe IDE, then create an java project(other is ok,too), then create an "Apache iBATIS IBator Configuration file". Then set the DB driver, connect setting, java model setting, sql map setting, dao setting and  table to domain obeject setting.
Attention, those setting create by Ibator default will not be delete, they are as a must!
 
SqlMapConfig.xml
<? 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 > 

   < classPathEntry  location ="E:\JavaDev\jars\mysql-connector-java-5.1.7-bin.jar"  /> 

   < ibatorContext  id ="MysqlTables"  targetRuntime ="Ibatis2Java2" > 

     < jdbcConnection  driverClass ="com.mysql.jdbc.Driver" 
       connectionURL ="jdbc:mysql://localhost:3306/ibatis_schema"  userId ="root" 
       password ="root"  /> 

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

     < javaModelGenerator  targetPackage ="ibator.models" 
       targetProject ="IbatisHelloWorld\src" > 
       < property  name ="trimStrings"  value ="true"  /> 
     </ javaModelGenerator > 

     < sqlMapGenerator  targetPackage ="ibator.maps" 
       targetProject ="IbatisHelloWorld\src"  > 
       < property  name ="enableSubPackages"  value ="false"  /> 
     </ sqlMapGenerator >    

     < daoGenerator  targetPackage ="ibator.daos"  targetProject ="IbatisHelloWorld\src" 
       type ="GENERIC-CI" > 
       < property  name ="enableSubPackages"  value ="true"  /> 
     </ daoGenerator > 
     
    <!--  set table to domainObject --> 
     < table  schema ="ibatis_schema"  tableName ="t_user"  domainObjectName ="User" > 
       < property  name ="useActualColumnNames"  value ="true" />     
       < generatedKey  column ="id"  sqlStatement ="MySQL"  identity ="true"     /> 
       < columnOverride  column ="name"  property ="name"  /> 

     </ table > 

   </ ibatorContext > 

</ ibatorConfiguration >
 
 
Online Docs of  Ibator
 
Source Download


    本文转自danni505 51CTO博客,原文链接:http://blog.51cto.com/danni505/177553,如需转载请自行联系原作者

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值