自己编译的ibator1.2.2

自编译的ibator1.2.2

apache ibatis项目已经终止,新的项目叫Mybatis。
相应的ibator代码生成工具也变了,终止之前最后的那个版本是ibator1.2.1。
浏览mybatis网站发现,有一个未发布的ibator1.2.2版本。
于是svn下载下来编译一番,凑合用用。
经测试eclipse 插件运行会报错(个人能力有限,对eclipse插件编写不熟悉),用ant或者手写代码的方式启动ibator没有问题。

ibator1.2.2中的新功能:


生成文件的变化:

1.selectByExample可以支持distinct
2.Example类增加了一个or方法
3.如果列名是sql关键字可以自动转义
4.select语句 重构,列名放在一个段 <sql id="Base_Column_List">中。
5.重新设计了eaxmple类,以便于extending,Criteria这部分发生了变化,
6.所有的addCriterionfor JDBC* method都进行了null检查
7.可以选择是否生成ibatorgenerated_前缀

配置文件的变化

8.table标签增加delimitAllColumns属性
9.可以为<columnOverrides>标签指定子标签<property>这个属性会传递到插件中去。
10.<table>增加useCompoundPropertyNames属性
11.可以将sql关键字自动转义:<ibatorContext><property name="autoDelimitKeywords" value="true"><property name="beginningDelimiter" value="&quote;"><property name="endingDelimiter" value="&quote;">  </ibatorContext>
sql关键字在org.apache.ibatis.ibator.internal.db.SqlReservedWords中

其他



12.IBATIS-569 - 插件体系增强
13.增加一个插件可以支持 忽略大小写的like在example类中
14.IntrospectedColumn类可以返回所有的数据库元信息,这样的话可以在CommentGenerators中添加数据库中的备注字段。
15.SqlMap namespace会设置在IntrospectedTable 的属性中,方便插件访问。
16.修改了IbatorRunner,以显示配置文件的错误。
17.EqualsHashCodePlugin now generates far superior methods 

另外

自己添加了一个cn/devit/impl/ibator/ClearCommentGenerator1.java,用来替代默认的CommentGenerator。 
这个CommentGenerator会在bean dao sqlmap添加更有意义的注释。例如字段名字,dao实现,接口文件名,sqlmap文件名,数据库中字段的注释,从而将这些个文件链接起来。(eclipse里面光标移到代表文件名的字符串上然后点F3) 

文件在另一个地方。

ant

<target name="ibator-all" description="Generate the files">
		<echo message="${basedir}/../devit-dev-util/dist/devit-dev-util.jar"></echo>
		<path id="ibator-lib">
					<pathelement location="\eclipse-galileo-3.5.2\dropins\ibator-1.2.2\plugins\org.apache.ibatis.ibator.core_1.2.2.201106071209.jar"/>
		</path>
			<taskdef name="ibator" classname="org.apache.ibatis.ibator.ant.IbatorAntTask"
					classpathref="ibator-lib" />
		<ibator overwrite="true" configfile="${basedir}/ibator-config-ant.xml" verbose="true" contextids="${contextids}">
			<propertyset>
				<propertyref name="generated.source.dir" />
			</propertyset>
		</ibator>
	</target>
代码方式

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;


public class IbatorConfigTest {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void test1() throws Exception{
		List<String> warnings = new ArrayList<String>();
		   boolean overwrite = true;
		   File configFile = new File("test/ibator-config-ant.xml");
		   IbatorConfigurationParser cp = new IbatorConfigurationParser(warnings);
		   IbatorConfiguration config = cp.parseIbatorConfiguration(configFile);
		   DefaultShellCallback callback = new DefaultShellCallback(overwrite);
		   Ibator ibator = new Ibator(config, callback, warnings);
		   ibator.generate(null);
		   for (String string : warnings) {
			System.out.println(string);
		}

	}

}
oracle如果想出comment的话必须在jdbc连接上添加属性:
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
			connectionURL="" userId=""
			password="" >
			<property name="remarks" value="true"/>
		</jdbcConnection>

转载于:https://my.oschina.net/lxbzj/blog/23799

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值