Ibator of Ibatis

 
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
http://ibatis.apache.org/docs/tools/ibator/
 
Source Download

你可能感兴趣的:(职场,休闲,ibator)