How to set fetchSize for iBatis select statement

nkukhar picture nkukhar · Jan 13, 2012 · Viewed 15.9k times · Source

I'm using iBatis as ORM framework in Java. I have a select statement

<select id="getList" resultMap="correctMap">
    SELECT *
    FROM SOME_TABLE
</select>

And I'm using queryForList method:

List<MappedObject> list = getSqlMapClientTemplate().queryForList("getList");

But it retrieves a big amount of data and performance of this query is pretty slow.

My assumption about this issues that iBatis has default fetch size (e.g. like in JDBS is 10) so that is why it so slow. So I want to set bigger fetch size (1000 for example). How I can do so?

Or am I looking in a wrong way?

NOTE: I need all data so set max results in queryForList method is not a appropriate solution for me.

List queryForList(String id,
                  Object parameterObject,
                  int skip,
                  int max) 

Answer

RokL picture RokL · Jan 13, 2012
<select id="SELECT_TABLE" parameterType="String" fetchSize="500" resultType="hashmap">
    SELECT * FROM TABLE WHERE NAME = #{value}
</select>