mybatis-generator 修改版
mybatis-generator 修改版
mybatis-generator.7z为git的详细修改记录,可用git进行查看。
mybatis-generator-test.7z为测试,只测试了生成的mysql和oracle的一些用法,其他的并未测试。
1、更新 SerializablePlugin插件变量serialVersionUID的位置 topLevelClass.addField(0,field);
2、增加了数据库的返回注释,去掉了不必要的一些注释
3、注释所有的接口方法
4、为ibatis2增加了个 给dao增加注解的插件
5、增加公共查询条件类 ibatis 和mybatis
6、增加了service的生成插件
7、增加pojo类注释-》table的注释
增加了几个插件类,可在package org.mybatis.generator.plugins包下面找到。
package org.mybatis.generator.update.update.txt为更新的记录
** 生成相关代码只需配置下对应的xml,在config/grid.xml,以及mysql.xml和oracle.xml里面是配置例子。 然后运行config包下面的_Ibator_Run_Test 即可,里面
public static void main(String[] args) {
_Ibator_Run_Test test = new _Ibator_Run_Test();
test.main1("grid.xml");
// test.main1("mysql.xml");
// test.main1("oracle.xml");
}
grid.xml是对应的配置文件名称。 **
增加了2个maven的工程,分别为修改后的mybatis-generator 1.3.1版本和test文件。
2011-08-30 更新:
8、默认不加入jdbcType属性,如:#{condition.myaccount,jdbcType=VARCHAR}或者 #condition.myaccount:VARCHAR#
如果需要使用,在<context 的下面配置
<property name="jdbcType" value="true" />即可
如:<context id="Ibatis2Java5" targetRuntime="Ibatis2Java5">
<property name="jdbcType" value="true" />
更新: 2011-09-13:增加了SQL Server获取数据库注释,字段注释的方法,只测试过2000版本。其他版本请自己测试。 2011-12-08:发现里面的方法只需要这样的参数就可以了。在xml里面省了一个 ,推荐使用这个版本的。
/**
* 根据条件更新属性不为空的记录
*/
int updateByExampleSelective(@Param("record") BaseModules record, @Param("condition") Map<String, Object> condition);
/**
* 根据条件更新记录
*/
int updateByExample(@Param("record") BaseModules record, @Param("condition") Map<String, Object> condition);
发现一个小问题,mysql表字段的注释生成正常,但是表本身注释不能读取,建议ConnectionFactory.getConnection增加props.setProperty("useInformationSchema", "true");//mysql需要个设置
楼主不错,我找了很久终于找到一个能用的,不知道有没有1.3.2的?
谢谢分享,我使用时,遇到了一个文件。 执行了_Ibator_Run_Test里面的main方法了,表也找到了,就是不见生成文件,请问怎么回事了。下面是日志
16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Retrieving column information for table "pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "id", data type 4, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "order_sn", data type 12, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "old_order_sn", data type 12, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "vendor_id", data type 4, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "vendor_name", data type 12, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "brand_name", data type 12, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "add_time", data type 93, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "vis_create_time", data type 93, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "is_export", data type -6, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "export_time", data type 93, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "delivery_time", data type 93, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "monitor_period", data type -6, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "delivery_state", data type -6, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "delivery_duration", data type 4, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "export_state", data type -6, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "export_duration", data type 4, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "vis_create_state", data type -6, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "vis_create_duration", data type 4, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "create_time", data type 93, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "update_time", data type 93, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug Found column "is_deleted", data type -6, in table "ofc_order_monitor..pop_delay_order_info" 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug 表名为:pop_delay_order_info 16:27:24 DEBUG org.mybatis.generator.internal.db.DatabaseIntrospector debug 表的注释为: 16:27:24 INFO org.mybatis.generator.plugins.MybatisCriteriaPlugin sqlMapDocumentGenerated 15
说错了。。属性我改成sizes相关代码都改成sizes 就没错了
condition是一个Map<String, Object> 为啥 size就无法识别呢 System.out.println(cri.getCondition().get("size"));我也答应了。。出来是null
我也换成sizes试过,还是有。。。
哥 我发现问题了。。绝对是BUG Pojo类{ private int id; private String size; .....
} test类{ ....省略一些 方法如下
mapper.xml里面 where条件
对吧。。。。这里都是配好的 结果一junit sql语句 select *from table where size =? parameter : null totalcount:0
别的pojo属性都是OK的 我也换过一个类,但是没有size属性,完全OK
蛮好用的,谢了
楼主你好,非常感谢你的贡献,不知道你能不能在业余时间写几篇关于如何去修改源码文章,我想定制自己想生成的代码,但是我根本就没头绪,不知道从哪个地方下手。非常感谢。
可以的,你自己做一个便是了,源码不是更好么。
不会用。不能做成一个jar包的形式吗?
好东西!!! :idea:
能不能留个QQ啊,使用时遇到问题了,28、29版本的使用时报错了,生成不了文件。好像grid.xml找不到
好的,谢了!
个人喜好直接用这个生成相关代码。运行config包下面的_Ibator_Run_Test这个类即可,
test.main1("grid.xml");这个是查找grid.xml配置文件,grid.xml里面配置的是相关的代码生成方式。
不知道怎么把这个 嵌入到 eclipse里面去。 望指教一下,谢谢!