Abator 的 selectByExample 方法需要 ibatis 2.2 支持
Abator 的 selectByExample 方法实现了类似 Hibernate 的使用方法:
SysMenuDAOImpl dao = new SysMenuDAOImpl();
SysMenuExample example = new SysMenuExample();
example.createCriteria().andMenuParentIdEqualTo(0); // 添加上极菜单 ID 等于 0 的条件
example.setOrderByClause(”MENU_ID”); // 按 MENU_ID 排序
List list = dao.selectByExample(example);
这种方法需要 ibatis 2.2 才能支持,ibatis 2.1 不能正常使用,ibatis 2.3 没有测试过。
它使用了 SqlMap 中的 include 方法,类似以下:
<sql id=”selectItem_fragment”>
FROM items
WHERE parentid = #value#
</sql>
<select id=”selectItemCount” parameterClass=”int” resultClass=”int”>
SELECT COUNT(*) AS total
<include refid=”selectItem_fragment”/>
</select>
<select id=”selectItems” parameterClass=”int” resultClass=”Item”>
SELECT id, name
<include refid=”selectItem_fragment”/>
</select>
SqlMap 中的 include 方法好像需要 ibatis 2.0 及以上版本才支持。
[ 标签: Abator, ibatis, SqlMap ][ 固定链接:http://blog.tanggaowei.com/2008/12/abator-selectbyexample-ibatis-22.html ]



1 个评论 - “Abator 的 selectByExample 方法需要 ibatis 2.2 支持”
suixing 发表于 2010-07-03 | 回复
大哥您真牛,向您学习。。。。。。
[Reply]