ibator生成的ibatis文件不带分页功能(或我没找到)。
最近研究了ibator源码,改造了下,适用mysql的分页。
大家可下载附件:ibator-guoba.rar
原理:
1、在生成的sql_map中加入limit语句,判断Example类中的pager是否为空。
2、生成BasePager类,含有pageStart,pagerEnd两个属性和方法,用于examplo继承。
3、在生成Examplo时加上继承BasePager
4、在DAOImpl中,对非select方法,接受example参数的方法判断不要传入pager(delete,update,insert)
生成ibatis文件:
1、写ibator.xml,配置数据源,dao, Model,sqlmap
2、点击 build.bat
java -jar ibator-guoba.jar -configfile ibator.xml -overwrite
3、生成的代码在 ibator-guoba\IbatorTestProject\src 下
程序中如何使用分页:
ConfigExample example = new ConfigExample();
example.createCriteria()..........;
example.setPageStart(2);
example.setPageEnd(10);
configDAO.selectByExample(example);
在非select时,置入pager时,会抛出参数异常。
源码介绍:
1、源码在ibator-guoba-src.zip中
2、生成BasePager类的代码在:
org.apache.ibatis.ibator.generator.ibatis2.IntrospectedTableIbatis2Java2Impl.getGeneratedJavaFiles()
3、生成Example加上继承BasePager
org.apache.ibatis.ibator.generator.ibatis2.model.ExampleGenerator
4、在DAO中检验非select方法不允许传入pager
org.apache.ibatis.ibator.generator.ibatis2.dao.elements.AbstractDAOElementGenerator.getExamplePagerCheckContent();
org.apache.ibatis.ibator.generator.ibatis2.dao.DAOGenerator
5、在sql_map中加入limit语句
org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.ExampleWhereClauseElementGenerator.addElements
分享到:
相关推荐
直接丢到eclipse的plugins目录下就可以了,在一些公司下载不了的地方,方便使用
iBATOR is a code generator for iBATIS.
ibator插件优化的jar包,安装完ibator后,将eclipse\plugins\org.apache.ibatis.ibator.core_1.2.1下的jar包替换即可。
ibator1.2.2多了点功能,具体可以百度,重新编译了下,生成注释去掉了
eclipse的集成插件,ibator.jar,可以直接mybatis导表,图形化展示,简单易用,直接放到eclipse的plugin文件夹下即可
ibator教学视频,手把手教你使用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 ...
在myelipse7.5中安装ibator插件的方法与安装一般插件的方法是一致的,有以下2种方式(个人推荐使用手动安装方式,避免网络等原因造成安装不成功): 1. 手动安装方式 将邮件中附件的Ibator插件压缩文件IbatorForEclipse...
eclipse的ibatis代码生成器,最新版ibator 1.2.1
ibator相对于hibernate框架能完全自主编写sql代码,同时又有hibernate便于管理的优点,是非常理想的持久层技术
做SSI项目时,Ibator映射出来的内容实在太多了,有很多内容都用不上,参考Ibator的结构,实现对基本字段和方法的映射!
自动生成dto\dao\xml 自带批处理自动生成程序
此项目通过对ibator的改造,通过执行cmd命令自动生成sql与Dao,大大提高开发效率
使用数据库的注释,不用自带的注释 http://blog.csdn.net/tiantangpw/article/details/43489817 运行命令 java -jar ibator.jar -configfile ibatorConfig.xml -overwrite >>ibator.log
ibator-config_1_1.dtd ibator用
Ibatis 生成器 Ibator 的 API 文档
ibator插件+ibatorConfig文件,加入到eclipse中,按照配置文件修改一下就ok了
ibatis 配置文件自动生成工具
去除了注释、去除Example方法及去除生成的id前面的“ibatorgenerated_”