Sparkle’s Workshop

iBATIS for Java 2.3.0 General Availability

Posted on March 15, 2007 - Filed Under Uncategorized |

iBATIS是一个经常与hibernate一起被提及的o/r工具,跟完全o/r化的hibernate不同,iBATIS算是一个半o/r工具,他仅仅提供了基本的映射功能,如果你要做一个很oo的db操作,可能hibernate比较适合你,如果你坚持使用JDBC,或许使用iBATIS会对你有不少帮助。尤其你想专注SQL语句的性能的话,hibernate并不适合。

最新版的iBATIS 2.3.0在2月11日发布了,没有太多大的更新,但是有两个很重要的功能废弃。其中一个是iBATIS的DAO部分被废弃,官方推荐使用spring。我倒不是不喜欢使用spring的事务功能,它的确做了很多事情,但是始终有些场景不是很适合使用。首先,spring的事务使用起来比较笨重,声明性的使用方法还好,但是要通过AOP,AOP相对麻烦一点,而且性能不高。编程性的使用方法用起来非常麻烦,使用模板的方法比较难看,不使用模板也难看。而且spring的事务速度会比较慢。其实iBATIS的事务做得挺简单的,其实就是JDBC的事务了,不过iBATIS有一点比较好的就是它使用而且

SendTransaction的风格

try {
beginTransaction();
xxxx
commitTransaction();
} finally {
endTransaction();
}

比起传统的

try {
beginTransaction();
xxxx
commitTransaction();
} catch(Exception e) {
rollbackTransaction();
}

的好处是,传统的做法其实是miss了Error的部分,而使用finally的做法,是肯定会执行的。

另一个废弃的功能就是paginate。的确ibatis做得比较鸡肋,仅仅是使用了jdbc的定位,废弃也是必然。hibernate里面这个特性倍受推荐,其实也做得并不完美。

Most Commented Posts

Comments

2 Responses to “iBATIS for Java 2.3.0 General Availability”

  1. winstarsNo Gravatar on February 1st, 2008 11:32 am

    请问如果采用2.3.0的话,是不是还能继续使用ibatis的dao framework呢?

  2. SparkleNo Gravatar on February 1st, 2008 3:52 pm

    iBATIS 2.3.0 is the current and best release. It is also the first iBATIS release that does not include the DAO framework.

    iBATIS 2.2.0 is also available. iBATIS 2.2.0 is the last release that includes the iBATIS DAO framework. After 2.2.0, the DAO iBATIS framework is removed from the downloads. We suggest converting iBATIS framework DAOs to the Spring Framework.

    http://ibatis.apache.org/javadownloads.cgi

Leave a Reply