Navigation: Home Java Tutorials Retrieving a CLOB in iBatis
Retrieving a CLOB in iBatis
Java - Tutorials
Friday, 05 November 2010 11:43

When I was but a youngling and the Force was yet to fully develop within me, I had issues calling stored procedures which returned a CLOB.

 

I'm pleased that those days are behind me (somewhat) and I now want to share my learnings with you.

It's really very easy and doesn't even require that you write your own custom type handler.

Just add the following to your SqlMapConfig

<typeHandler javaType="java.sql.Clob"
 callback="com.ibatis.sqlmap.engine.type.ClobTypeHandlerCallback"/>

What this does is force Ibatis to use the specified handler when dealing with the java type specified. So in this case, we're telling Ibatis to use the ClobTypeHandlerCallback when dealing with objects of type java.sql.Clob.

Just one other step is required. Ensure that you have the correct type mapping in your parameter map.

<parameter property="r_clob" jdbcType="CLOB" javaType="java.sql.Clob" mode="OUT"/>

Remember to cast your return value when getting it back.

String c = (String) params.get("r_clob");

And viola! That's it. Go ahead and test it out.

Enjoy.

 

Twitter Feed

reegz786
Java developer with delusions of Flex.. Living the developers dream
reegz786
reegz786: Just got asked if I've ever heard about the Balanced Scorecard. @CubicThoughts

12 hour(s) ago from Twitter for Android

reegz786
reegz786: #Ubuntu now on #android #linux #ftw http://t.co/LEsOc6v9

12 hour(s) ago from Twitter for Android

reegz786
reegz786: Never do business with friends.

2 day(s) ago from Twitter for Android



powered by TweetXT!