数据表

createtabletest(TASKIDNUMBER(10)notnull,CONFIGCLOB)

controller

@ResponseBody@RequestMapping("/getTest")publicListgetTest(HttpServletRequestrequest,HttpServletResponseresponse){returnthis.Service.getTest();}

sql.xml

<selectid="gettest"resultMap="hashmap">selectt.configasconfig,t.taskidfromtestt</select>


1、没有做任何处理情况,程序报错如下

Causedby:org.codehaus.jackson.map.JsonMappingException:Noserializerfoundforclassoracle.sql.LobDBAccessImplandnopropertiesdiscoveredtocreateBeanSerializer(toavoidexception,disableSerializationConfig.Feature.FAIL_ON_EMPTY_BEANS))(throughreferencechain:java.util.ArrayList[0]->java.util.HashMap["CONFIG"]->oracle.sql.CLOB["dbaccess"])

2、在sql.xml中,对CLOB字段Config进行to_char()处理,开始能够解决问题,后面出现数据库报错的情况

sql.xml

<selectid="gettest"resultMap="hashmap">selectto_char(t.config)asconfig,t.taskidfromtestt</select>

数据库报错

3、去掉@ResponseBody,将返回的结果打印出来,发现config是一个对象

controller

//@ResponseBody@RequestMapping("/getTest")publicListgetTest(HttpServletRequestrequest,HttpServletResponseresponse){System.out.println(this.Service.getTest());returnthis.Service.getTest();}

debug

[{CONFIG=oracle.sql.CLOB@16e2b70,TASKID=38}]

4、在Mybatis中采用resultMap处理,程序正常,debug时config为具体内容。

sql.xml

<selectid="gettest"resultMap="testMap">selectt.configasconfig,t.taskidfromtestt</select><resultMaptype="hashmap"id="testMap"><resultproperty="CONFIG"column="config"javaType="String"jdbcType="CLOB"/><resultproperty="TASKID"column="taskid"/></resultMap>