使用hibernate的createSQLQuery进行查询clob类型数据的时候发现问题:
查询出来的数据是一个内存地址,那现在问题怎么解决呢?
public String findEmail() throws IOException{
// 获取邮箱
Session currentSession = this.currentSession();
String sql = "SELECT VALUE_TEXT FROM table WHERE DICT_CODE = 'EMAIL' ";
SQLQuery query = currentSession.createSQLQuery(sql);
Clob clob = (Clob) query.list().get(0);
Reader inStreamDoc = null;
String email ="";
try{
inStreamDoc = clob.getCharacterStream();
char[] tempDoc = new char[(int) clob.length()];
inStreamDoc.read(tempDoc);
email = new String(tempDoc);
}catch(SQLException e){
System.out.println("***Action clob转换String类型失败" + e);
}catch(IOException e){
System.out.println("***Action clob转换String类型失败" + e);
}finally{
inStreamDoc.close();
}
return email;
}