为 Ibatis 2.3.4 构建增强的 Apache Ibator 实体类生成工具

ibatis

Introduction to Ibator

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.

 

 

Apache Ibatis 已经从 apache 基金会迁移到了 Google, Ibatis 已经从 2.3.4 升级到了 3.0.1,并且名称由“Ibatis” 改名为“MyBatis”。然而到目前为止,ibatis 的自动化实体类生成工具 ibator 还迟迟没有更新。由于以前的项目用的还是 ibatis 2.3.4,而新版的 MyBatis 3.0.1 的变化很大,如果升级的话以前的程序得做非常大的调整。

 

这里把我以前修改完善的一个 ibator 程序分享出来,做了很多完善:

 

  • 去掉了实体类和 xml 映射文件中所有无用的 "generated by apache ibatis ibator" 的提示
  • 增加 javaHeaderComment  和 xmlHeaderComment 属性,用于在实体类和 xml 映射文件中生成文件头(标注版权作者信息等)
  • 增加 targetFileEncoding 属性,可以将实体类和 xml 映射文件输出为多种格式,支持:ASCII, UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE
  • 增加了一个 ${ProjectPath} 变量,用于在配置文件中代替 .jar 文件所在的路径
  • 增加 datetimeFormat、dateFormat、timeFormat 属性,用于支持自定义日期时间格式
  • 将实体类语法方案方式改为 C++ 样式(花括号、空格等的显示方式)
  • 为表的字段类型 整形、浮点型、时间日期型、BLOB 型,增加了 String 参数类型的 set、get 方法(原先默认只有对应 java 类型的参数,现在都可以直接传入 String 类型,比如 setSomeBlobAsString,这里的 SomeBlob 就是个 BLOB 的字段类型 )
  • 为实体类的 Example.Criteria 类增加了 andSomeColumnEqualTo、andSomeColumnNotEqualTo、andSomeColumnGreaterThan、andSomeColumnGreaterThanOrEqualTo、andSomeColumnLessThan、andSomeColumnLessThanOrEqualTo、andSomeColumnBetween、andSomeColumnNotBetween 方法,用于重载同名函数,增加了 String 参数类型,这里的 SomeColumn 是某字段名
  • 为实体类 DAO 和 xml 映射文件增加了 countAllRecord、 deleteAllRecord、selectAllRecord 三个方法和 SQL 映射
  • 其他未尽事宜请参考生成的实体类和 xml 映射文件吧
  •  

     

    下载地址:http://download.csdn.net/source/2536605

     

     

     

    备注:

    1、原 ibatis 2.3.4 官方网站:http://ibatis.apache.org

    2、原 ibator 1.2.1 官方地址:http://ibatis.apache.org/ibator.html

    3、新的 MyBatis 官方网站:http://www.mybatis.org/java.html

     

     

     

     

     

     

     

     

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值